• If a post has multiple categories, then the single.php page will display ALL categories under which it is posted.

    I want to restrict this display. Let me give an example.

    Suppose an item is posted under cat1, cat2, cat3, the “the_category” will display ALL the categories no matter what is the template.

    So if a visitor goes to Cat1, then the display I would want is like is:
    Posted under Cat1.
    Additionally I may or may not want this also to be displayed:
    Also posted under: Cat2, Cat3.

    In this case, I get to do a couole of things:
    (i) Make it easy for the visitor to browse Cat 1 only.
    (ii) Display a category specific masthead for the item. So if item xxx is posted under Cat1, Cat2, Cat3, then http://www.domain.com/?p=xxx should display Cat1 masthead if one accesses the item from the Cat1 page and so on. If none of these are applicable, then the default masthead should be displayed.

    Now now, is this possible?

Viewing 1 replies (of 1 total)
  • Thread Starter write2kill

    (@write2kill)

    This is unlikely to work I gather.

    <?php
    $post = $wp_query->post;
    if ( in_category(‘1’) ) {
    include(TEMPLATEPATH . ‘/masthead1.php’);
    } elseif ( in_category(‘2’) ) {
    include(TEMPLATEPATH . ‘/masthead2.php’);
    } elseif ( in_category(‘3’) ) {
    include(TEMPLATEPATH . ‘/masthead3.php’);
    } else {
    include(TEMPLATEPATH . ‘/masthead0.php’);
    }
    ?>

Viewing 1 replies (of 1 total)

The topic ‘Restrict post to a category’ is closed to new replies.