Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

zebrastribe on "Exclude categoies from wp_list_categories?"

$
0
0

Hi all

I am using this from the codex:

<?php
$taxonomy = 'category';

// get the term IDs assigned to post.
$post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
// separator between links
$separator = ', ';

if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) {

	$term_ids = implode( ',' , $post_terms );
	$terms = wp_list_categories( 'title_li=&style=none&echo=0&taxonomy=' . $taxonomy . '&include=' . $term_ids );
	$terms = rtrim( trim( str_replace( '',  $separator, $terms ) ), $separator );

	// display post categories
	echo  $terms;
}
?>

[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

But I have a hard time adding a exclude to hide some categories from the list.
I tried this:
$terms = wp_list_categories( 'title_li=&exclude=1&style=none&echo=0&taxonomy=' . $taxonomy . '&include=' . $term_ids );
and
$terms = wp_list_categories( 'title_li=&style=none&echo=0&taxonomy=' . $taxonomy . '&include=' . $term_ids . '&exclude=1');

Why is the category not excluded from the list?


Viewing all articles
Browse latest Browse all 8245

Trending Articles