I have a category 'c program'. I can show this category using category.php template file. I have a post like 'First C program' under 'c program' category. So I want to use another template file for this post. As far I know this can be done using single.php. But this template file is not showing this post.

more specifically:

  • example.com/category/c-program (category.php is working here).
  • example.com/category/c-program/first-program (single.php is not working here).

Any idea?

  • So you have a standard normal post named "First C Program"? Keep in mind that single.php applies to all singular posts, not just that one, and is a fallback. Have you tested which template is actually being loaded? Query Monitor exposes that information. Have you checked the template hierarchy diagram? It's definately not a custom post type? Have you created a more specific template already? – Tom J Nowell Jun 2 '18 at 20:04
  • I just post a standard normal post. I explored template hierarchy diagram. It's definately not a custom post type. I created singel.php template. – Abdus Sattar Bhuiyan Jun 3 '18 at 5:25
  • Have you considered flipping the problem on its head? What you ask for taken literally would lead to ambiguity problems. E.g. if the post is in more than 1 category, there's no correct answer as to which category template to load, so this becomes a problem. Instead, if you want the post titled first-program to have its own template, create single-first-template.php instead – Tom J Nowell Jun 3 '18 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.