I have been trying to use WordPress as a CMS, but I seem to have misunderstood the way in which category-[N].php is called. I have searched the site extensively, but have now drawn a blank. I would be grateful for some help. Sorry about the long description of the background; I thought it might be relevent, in case there’s something fundamentally wrong with my approach.
Background: Using WP2.5.1, I wanted to be able to post three different types of content: blog posts, articles, and essays. These three menu items were to appear in the top menu, and for each to return a list of the content-type-posts, or in the case of the blog, the five latest blog posts. So far, so good. I have created page templates for essays and articles, by creating essays.php, and declaring it as “Template Name: essaysPage”, and then creating a page, using ‘essaysPage’ in the ‘template parent’ parameter in ‘Write Page’, to get a menu item. Then using the line …query->query(‘showposts=5′.’&cat=[N]’. … to restrict the search to the relevent category. The blog works perfectly, and I’ve got the plugins to not display non-blog posts in the archive, and calender, and recent posts by altering the SQL queries in the plugins. And as I intended, the articles and essay pages, do not show the blog-related sidebars.
Problem: Now, however, although I have created category-[n].php for posts belonging to categories essays and articles, WordPress continues to display the files using single.php, meaning I get sidebars where I don’t want them. I had understood that WordPress would pick up on the category for the post, and search first for the template relating to that category. Have I misunderstood anything?
It occured to me that I may have been doing a de-facto ‘archive’ search, and that perhaps single.php is always the outcome from this kind of search. Is the only solution to put some conditional code into single.php? I am worried that this may be messy.
- The topic ‘Displaying single.php instead of Category-x.php’ is closed to new replies.