• Two Categories in the same Post.
    I was trying to apply to a single post two different categories for two different ways of seeing the same Post. So as usual I go to ( single.php ) and add this:

    <?php
    /*
    Single Post Template: Single Play
    Description: Post Template
    */
    ?>
    <?php
    $post=$wp_query->post;
    $cat = array(5);
    if(in_category($cat)) {
    include 'single-custom.php';
    
    } else if ( in_category( 'lux' ) ) {
    
    ?>
    
    <?php get_header('single'); ?>
    & more...

    the permalink structure:
    %category%/%postname%

    except that when I try to watch the same post in two different categories, is presented in the same way taking into account only the first cat => (5) name == cobalt, in alphabetical order of appearance.

    Is there a way to give two distinct categories in the name and then also in the style?
    tnx Mario

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter webbeloz

    (@webbeloz)

    evolution to find the solution…

    This is another way to check if the Single Post responds to the category, but I’m always up at the head.

    Always makes ALPHA. :-\

    <?php if( is_category( 'alpha' ) || is_single() &&    in_category('alpha') ){ ?>
    
       <?php echo 'ALPHA'; ?>
    
    <?php } elseif( is_category( 'beta' ) ||  is_single() && in_category('beta')            ){ ?>
    
       <?php echo 'BETA'; ?>
    
    <?php } ?>
    Thread Starter webbeloz

    (@webbeloz)

    ok, that explanation:

    Assign two different styles to a single post, through the use of two categories and think of making two visions and two styles is impossible. However, it is possible through the duplication of the post that remains hidden in the database and then assign a category dummy with:

    <?php if( is_category( 'alpha' ) || is_single() &&    in_category('alpha') ){ ?>
    
       <?php echo 'ALPHA'; ?>
    
    <?php } elseif( is_category( 'beta' ) ||  is_single() && in_category('beta')            ){ ?>
    
       <?php echo 'BETA'; ?>
    
    <?php } ?>

    I now see CAT-alpha with a style and CAT-beta with another.
    So there is the mystery of the categories to which I aimed.
    End! of trick..(:

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Two Categories in the same Post’ is closed to new replies.