Thando Hlophe
Thando Hlophe

Reputation: 67

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

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

I have a href

<a class="viewCar" 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

Upvotes: 0

Views: 34

Answers (1)

Vijay Hardaha
Vijay Hardaha

Reputation: 2604

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

Upvotes: 2

Related Questions