• I’ve been scouring search engines and help blogs for hours, but I can’t get to a solution. ??

    In my single post code (single.php), I use the following snippet to display all categories where the single / individual post belongs to:

    Filed under <?php the_category(', ') ?>

    Some of my posts belong to two categories, but the two categories don’t appear on the portion where the above code was placed.

    Example page: https://www.pinoyengineers.com/2010/08/resolution-no-2004-211/

    This post is filed under two categories: “Instruction to examinees” and “Laws”. Weird as it may seem, look at the end of the post to see the categories where it is placed:

    Filed under Laws (but the link points to “Instruction to examinees”)

    I want this part to appear as:

    Filed under Instruction to examinees, Laws

    HELP!

Viewing 5 replies - 1 through 5 (of 5 total)
  • use this once get_the_category_list( ‘, ‘ )

    In WordPress 3.0 they are using this method to show categories and tags.

    $tag_list = get_the_tag_list( '', ', ' );
    	if ( $tag_list ) {
    		$posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
    	} elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
    		$posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
    	}
    printf(
    		$posted_in,
    		get_the_category_list( ', ' ),
    		$tag_list,
    		get_permalink(),
    		the_title_attribute( 'echo=0' )
    	);

    Thread Starter davaobase

    (@davaobase)

    Thanks for the replies, chinmoy29 and Kapil Chugh. I tried both of your suggestions as such:

    1. I used echo get_the_category_list(', ') to display the category list, but it still shows only one category.

    2. Kapil, I used your exact code, which also made use of the get_the_category_list function. Still, only one category is showing.

    Any other suggestions?

    Thread Starter davaobase

    (@davaobase)

    GOT IT!

    I used the following code to list all categories where the specific post is filed under, including the links to the categories:

    <?php echo get_the_term_list( $post->ID, 'category', '', ', ', '' ); ?>

    I just treated “category” as a taxonomy. ??

    Thx for sharing it.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘the_category doesn't list all of the categories’ is closed to new replies.