WordPress.org

Ready to get started?Download WordPress

Forums

Trouble displaying post's categories excluding one (1 post)

  1. Number_6
    Member
    Posted 5 months ago #

    This is my code:

    <div class="byline">
    <?php
    if ( in_category('1') ) {
    	_e("Show:<?php wp_list_categories('orderby=name&exclude=1,183,192,13'); ?>");
        echo apply_atomic_shortcode( 'byline_tags', '<div class="byline">' . __( '[entry-terms taxonomy="post_tag" before="Host(s): "]', 'ascetica' ) . '</div>' );
    } elseif ( in_category('183') ) {
    	_e("Genre(s):<?php wp_list_categories('orderby=name&exclude=1,183,192,13'); ?>");
    } elseif ( in_category('192') ) {
    	_e("Game Type:<?php wp_list_categories('orderby=name&exclude=1,183,192,13'); ?>");
    } elseif ( in_category('13') ) {
    	_e("Movie Category: <?php foreach((get_the_category()) as $cat) {
      if (!($cat->cat_name=='movie-reviews')) echo $cat->cat_name . ' ';
    } ?>");
    } else {
     _e("Filed under:<?php wp_list_categories('orderby=name&exclude=1,183,192,13'); ?>");
    }
    ?></div>

    It's a bit muddled since I've been trying different methods.
    What I'm trying to do: Depending on which category php displays a different label for the categories, then list the categories the post is in excluding parent categories.

    A different approach instead of using if and ifelse is to make a post template for every type of post and list my labels differently in each one. But first I want to figure out displaying categories properly.

    What's wrong with my code?

    Thanks

Reply

You must log in to post.

About this Topic

Tags

No tags yet.