understanding template hierarchy
-
I want to be sure I understand what happens when someone clicks on a link on my site. I am currently building my own theme and have a front page display of thumbnails of posts in several categories. What I want to happen is when someone clicks on one of those, they end up going to a page that shows more thumbnails of posts in a specific category. I know how to display those, I’m just unsure how I get to that file.
From the Theme Handbook I read,If your blog is at https://example.com/blog/ and a visitor clicks on a link to a category page such as https://example.com/blog/category/your-cat/, WordPress looks for a template file in the current theme’s directory that matches the category’s ID to generate the correct page.
So if I have a template file called category-whatever.php, and if someone clicks on the thumbnail representing “whatever” on my home page, WordPress looks for that category-whatever.php file? If I’ve got that correct, that’s great. It’s just completely different from what I’m used to when writing code for other things. Where is the little elf in WordPress that makes the decision? I can see a couple of files in the call stack in netbeans when I’m debugging.
- The topic ‘understanding template hierarchy’ is closed to new replies.