Display Custom Post template name in wordpress

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

Read More
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.

Related posts

Leave a Reply

2 comments

  1. 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.

    $post_meta      =   get_post_meta($post->ID);
    $post_template  =   $post_meta['custom_post_template'][0];
    

    This will return me the name of post-template. And now conditions can be used like this

    if($post_template == 'two-column-right-menu-post.php'){
        ?> <link href = 'style.php'> <?php
    }else{
        ?> <link href = 'style1.php'> <?php
    }
    

    Or this is better solution

    $post_template  =   get_post_meta( $post->ID, 'custom_post_template', true );