Want to apply different custom single post page templates in a single site
-
Hello everyone
I have to prepare different custom single post pages to apply within the same website becaue my client probably wants me to apply different templates to two different types of service detail pages.
I understand single-post-[slug].php or single-[post-type].php can let you separately apply single post templates. The problem is that the client doesn’t want to enter a page slug or select a custom post type for each post.
Consequently, I spent hours lookng for ways to achieve the separate application of templates and Method 1 introduced here seems most promising.
Method 1 presented above indeed returns some kind of an array containing the category name using this code:
$category = $wp_query->get_queried_object();
However, I cannot work out how to make WordPress get only the category name, property-detail, from the array:
4312018-03-14 10:28:182018-03-14 01:28:18property-detailpublishclosedclosedproperty-listing2018-03-20 13:20:312018-03-20 04:20:310https://localhost:8080/aozora-estate/?page_id=430page0raw
The next code introduced in Method 1 also fails to get the category name:
$cat_name = $category->name;
So I would like to know how you can only get the category name using get_queried_object() or if there is any better tried and tested way to achieve the same goal. Please someone help me.
Thank you in advance,
Ead
- The topic ‘Want to apply different custom single post page templates in a single site’ is closed to new replies.