I need to display custom post template name.
Actually i want to load different css for each custom post template.
For this i need the custom post template name but i cant find it anyhow.
Here is the structure of my directory.
index.php
single.php
header.php
footer.php
fullpage-post.php // This is custom template
two-column-right-menu-post.php
two-column-left-menu-post.php
Now in header i want something link this
if($custom_template->name == 'two-column-right-menu-post'){
?> <link href = 'style.php'> <?php
}else{
?> <link href = 'style1.php'> <?php
}
How can i achieve this. I googled around and could not find the solution.
You should take a look at get_page_template.
A side not you are including css wrong. You should not use
<link>
to include styles but you should use wp_enqueue_style, this allows stuff like caching and minify.Roughly the same goes for javascript which has wp_enqueue_script
A good tutorial about it: http://halfelf.org/2012/jquery-why-u-no-enqueued/
After digging into wordpress database i have found a solution for this. Here is it.
AS i have added custom-post-template plugin in my application and able to create and attach templates to post i found this solution.
This will return me the name of post-template. And now conditions can be used like this
Or this is better solution