• Resolved gluehbirne

    (@gluehbirne)


    Hi,

    i got a category “thema” and a single-thema.php – but wordpress is not using the single-thema.php – it uses the single.php.

    I have got no idea why and i do not know where to look at first to solve my problem. i use the WP Bootstrap Starter Theme.

    I cannot post a link because it´s still on localhost. If I follow https://developer.wordpress.org/themes/basics/template-hierarchy/ it should be enough to create a single-thema.php, isn´t it?

    • This topic was modified 4 years, 9 months ago by gluehbirne.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    “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.”

    Category is not part of the hierarchy for single posts.

    What I’d do is to use the get_template_part function in single.php with an if (or switch/case) statement to load a content-categoryname.php template based on the post’s primary category.

    Thread Starter gluehbirne

    (@gluehbirne)

    Oh, okay. Then I obviously misunderstood the article.

    I try to do what you suggested. Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘single-{slug}.php is not working’ is closed to new replies.