I have a certain post displayed and each post i click go to single page which shows more details of the post. But i have different templates for the post details which will be shown in single page.

<?php query_posts('post_type=posts&category_name=design'); while(have_posts()): the_post(); ?>

<a href="<?php the_permalink(); ?>">Details</a>

<?php endwhile; wp_reset_query(); ?>

now in single.php I want to make a conditon where the_permalink could pass a slug maybe? then i could i include the template for design details.


<?php get_header(); 

 $categorySlugName = single_cat_title(true);

if($categorySlugName == 'design'){

  include 'design-details.php';


1 Answer 1


It was pretty simple. after going through the wordpress codex,

just had to change the second line on single.php

$categorySlugName = single_cat_title(true);


$cateogrySlugName = get_category_by_slug($slug);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.