Home > Blockchain >  Wordpress custom theme development: single-{post_type}-{slug}.php hierarchy explained
Wordpress custom theme development: single-{post_type}-{slug}.php hierarchy explained

Time:11-21

I am developing custom wordpress websites, the page hierarchy has been a hard concept for me to understand 100%.

I have a href

<a  id="15" href="/BWM/M4">........</a>

In the wordpress backend:
BMW is a page
M4 is a post

Now in my files, i have created a file called
single-{post_type}-{slug}.php

When i click the href, the URL should be www.car.com/BWM/M4 but i get www.car.com/M4

Secondly the page defaults to the index.php skipping all the other suggested pages from https://developer.wordpress.org/themes/basics/template-hierarchy

CodePudding user response:

Posts are different from pages, You need to check the page template documentation

If you just have to customize one page then you can use the page-{slug}.php way otherwise I will suggest you to use Custom page template option

  • Related