Theme Dev- Pages inherit template from single.php how do I change template

Nathan 3 years ago in Club updated by Andrei S. (Developer) 3 years ago 2

How do I target the specific page to change the template while I develop the theme.

I know about changing templates and saving to "theme/anwp-football-leagues" but this only changes things within the "content area" of the theme. I want to change the template for the actual theme and pull in a different sidebar.

My first guess was to create single-club.php but hasn't worked. What am I missing?

I spent 3 hours working out this morning, come back and posted this. 20 minutes later and a fresh look helped me work it out myself. So here's to help others

the template file I needed to create was "single-anwp_club.php"

this anwp_ prefix should work on all template theme files.


It is a common rules for all themes. It is written in "Template Hierarchy".

- https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post

  1. single-{post-type}-{slug}.php – (Since 4.4) First, WordPress looks for a template for the specific post. For example, if post type is product and the post slug is dmc-12, WordPress would look for single-product-dmc-12.php.
  2. single-{post-type}.php – If the post type is product, WordPress would look for single-product.php.
  3. single.php – WordPress then falls back to single.php.
  4. singular.php – Then it falls back to singular.php.
  5. index.php – Finally, as mentioned above, WordPress ultimately falls back to index.php.

Plugin has registered post types:

- anwp_club
- anwp_competition
- anwp_match
- anwp_player
- anwp_stadium

P.S.: prefix used to prevent conflicts with other plugins.