Have you ever wanted to be able to serve up an alternative version of your posts, perhaps tweaking the layout or even the content of the posts? Not all the time, just in certain circumstances?
I’ve had two cases recently where I’ve needed to do this. My solution: to change the post template when a certain URL parameter is added to the URL. Continue reading
Here’s how to delete all the terms in a taxonomy, whether it be category, tags or a custom taxonomy. Most sites will never need to do this – and there are probably better ways to do this – but here’s the code anyway.
If you have a category page which has no posts, it will normally trigger your theme’s no posts found message. Seems sensible! However, I have an edge case where I don’t want that message displayed.
The Categories widget in WordPress uses the category description as the title attribute for the list items displayed by the widget. While this may be great for very short descriptions, it doesn’t make sense when longer descriptions are in use.
Tonight I read an article on WPTuts+ titled 10 Quick Tips: Optimizing & Speeding Up Your WordPress Site. For the most part it’s a good article with lots of great tips, but there is one tip which is just plain incorrect:
Using a constant instead of
get_option('home'); saves a database call.
I recently wrote about displaying ads only to search visitors in WordPress. A key part of the technique described is to set a cookie, identifying the visitor as having come from a search engine. It should have been simple, but my PHP setcookie command didn’t appear to work. Continue reading
WP Super Cache has a setting which allows the cache to be cleared when a post is saved. I needed to clear the cache when a widget is saved. It turned out to be surprisingly easy.
I recently came across a strange problem with the fetch_feed function in WordPress not working with URLs containing the & symbol. The URL was being passed to fetch_feed via a shortcode parameter, but fetch_feed couldn’t find the feed.
I’ve read quite a few articles on theme support for the new Menu functionality introduced in WordPress 3.0. However, these have all been theoretical rather than practical. I wanted a real life, working example, including support for users on older versions of WordPress. In the end, I wrote it myself.
WordPress Theme developers, listen up! When updating your themes to work with the new menu functionality, you need to make sure that it still works with older versions of WordPress.
When I’m working on WordPress related development (ie themes and plugins), I like to run WordPress locally. This is great for trying things out before it goes live and also lets me squeeze in some development time in on the train!
My web server package of choice is XAMMP Lite, the Apache distribution that contains PHP and MySQL. Works great in general, but I had some problems with WordPress permalinks and XAMMP Lite. Here’s the solution.
So far, my WordPress development work has consisted of writing WordPress plugins and occasionally hacking themes. I’ve always said that I wanted to write a WordPress theme from scratch, but never had time to do so. One of my sites is going to need a redesign shortly, so here’s my big opportunity.
However, with the rise of the WordPress theme framework and the limited time available to me, I’ve started thinking that the sensible thing to do is use a theme framework. But which one?
Custom page templates are a powerful feature of WordPress that can be used to make pages (not posts) do something different from normal. You can make them do pretty much anything. Obviously, this can greatly increase the flexibility of your site.
Amongst other things, I’ve used custom page templates to create a basic photo wall and a dynamic listing of jobs in China.
However, because of the way most WordPress themes are created, calling an external CSS file from a custom page template is not straightforward. Here, I explain the problem, look at the options and explain how to use ‘plugin functionality’ to overcome the problem.