Support » Plugin: Custom Post Type UI » Custom Post Type Single Template If In A Specific Category

  • Resolved antsanwp

    (@antsanwp)



    Hi!
    I have a custom post type named “wiki”.
    I want to create a different single wiki template file based on the taxonomy “category_wiki” ID with conditions in single-wiki.php.
    I’ve used “in_category” but it’s not working. How can I solve it?

    Es:

    <?php
        if (has_term( '14', 'category-wiki')) {
            include('/cat/wiki/single-wiki-cat14.php');
        }
        else {
    	include('/cat/wiki/single-wiki-default-template.php');
        }
    ?>
    • This topic was modified 7 months, 1 week ago by  antsanwp.
    • This topic was modified 7 months, 1 week ago by  antsanwp.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Michael Beckwith

    (@tw2113)

    a couple quick notes just based on what I can see there.

    Try 14 without the quotes, just in case WordPress core isn’t discerning integer from string in this case. Also make sure your taxonomy matches. You show “category_wiki” with an underscore, but the value passed for that parameter is “category-wiki” with a dash.

    Plugin Author Michael Beckwith

    (@tw2113)

    Any changes or perhaps successes with this one @antsanwp ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Post Type Single Template If In A Specific Category’ is closed to new replies.