[ Tag Archive ]
Using PHP to Remove an HTML Tag from a String
There are times when you need to strip one specific HTML tag from a string and the PHP function strip_tags() doesn’t work the way you want it to. strip_tags() allows for certain exclusions, but why would you use that when you only want to exclude one tag and include all other tags? Especially when you can use preg_replace().
How to List Your Most Popular Posts in WordPress
I decided my sidebar was looking a little plain. It needed something more than just ads, so I placed a list of my popular posts there. I think it looks pretty cool and it was very simple to do. I just created a PHP function and added it to my functions.php files and then added some styles to get it to look the way I wanted.
Add Time to the Date Function in PHP
I just needed to do this for a client’s site to set an expiration date for a user and I thought it might be something that other programmers might like to know how to do. If you need to take today’s date and add time to it it is pretty simple. There is a PHP function called date() and another called strtotime(). You need to use both to make this happen.
Remove the Title Attribute from WordPress Category and Page Lists
I was creating a drop down menu for the categories in my Magazine Basic theme and I came across something that started to annoy me a bit. When you hover over the menu item, and the sub-menu dropped down, a title attribute would appear and cover some of the menu. This title attribute it hard wired into WordPress. Just hover over any menu item above and you will see a yellow box appear that says something like “View all posts files under…”.
This is a useful attribute to add to any site in regards to the Web Accessibility Initiative, but if it interferes with the basic navigation of your site, I think it is okay to nix it.
How to Create a WordPress Widget
While I was developing my Magazine Basic 2.0 backend interface, I decided to include a few widgets that I thought would be useful. The only problem was I had no clue how to do it.
I knew that I need to add the code to the functions.php file in the theme I was using but that was pretty much it. I ended up just looking at the widgets that are included with WordPress 2.7 and dissected how they functioned to figure out for myself how they were programmed. It is quite elaborate but if you understand PHP and really look at it you can easily figure out exactly what is going on.





