0
Answered
Theme Dev- Pages inherit template from single.php how do I change template
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?
Customer support service by UserEcho
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
single-{post-type}-{slug}.php
– (Since 4.4) First, WordPress looks for a template for the specific post. For example, if post type isproduct
and the post slug isdmc-12
, WordPress would look forsingle-product-dmc-12.php
.single-{post-type}.php
– If the post type isproduct
, WordPress would look forsingle-product.php
.single.php
– WordPress then falls back tosingle.php
.singular.php
– Then it falls back tosingular.php
.index.php
– Finally, as mentioned above, WordPress ultimately falls back toindex.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.