My love for Wordpress is no secret. I love it because it takes the focus off of how to display content and let’s website publishers produce better content. But every now and then there comes a time when you have to get your fingers dirty.
I was looking for a way to display more than my predetermined “show posts setting” when my site’s visitors are searching through my archives, tags, or categories. I like a nice clean home page, usually only showing 3 – 5 posts, but that same setting on on an archive page make the page appear pretty bare. After a quick little bing I came across a Custom Query String plugin hosted at How To Geek that looked like it would do everything I wanted. As a matter of fact it almost did.
The plugin allows me to determine how many post item are displayed based on the page type. So now I can show my 3 blog posts on the front page, but 20 category posts on the archive page. The only type of post query it didn’t account for was tags. Looking through the code of the plugin it seemed easy enough to make this bend to my will. All I ended up doing was adding the is_tag attribute to the plugins condition array:
/*
added at line 52
*/
var $conditions = array('is_archive', 'is_author', 'is_tag', 'is_category', 'is_date', 'is_year', 'is_month', 'is_day', 'is_time', 'is_search', 'is_home', 'is_paged', 'is_feed');
and adding a qualifying ifelse to check for the added array value:
/* added at line 197 */ elseif ($wp_query->is_tag AND $this->options['is_tag']) $this->query = 'is_tag';
Sure enough, that was all it took. My tags, categories and archives are now formatted just the way I like them. This really speaks to programming abilities of Matt Read. After one quick look through of his code I knew exactly what to change and where to get the code to behave exactly how I wanted it do.
Related posts: