0
votes

Below is my code for the category list displayed on this page

http://www.surefiresearch.com/blog/

I want to remove the categories 'page-seo' and 'page-seo-1'. I am trying 'exclude=cat_id' which has worked for preventing the actual posts from displaying on this page, but it doesn't work for the list of categories.

Can anybody see what I am doing wrong?

Cheers.

$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 . '&exclude=66,67');
    $terms = rtrim( trim( str_replace( '
    ', $separator, $terms ) ), $separator );

    // display post categories
    echo $terms;
}
1
It may be that you can't use include and exclude as criteria in the same call (not sure about wp_list_categories, but it's true for other functions, such as wp_tag_cloud). What happens if you remove IDs 66 and 67 from $post_terms and only use include? - Hobo
This worked wp_list_categories('orderby=name&show_count=1&exclude=66,67,68,69,70,71&title_li='); - user3647602

1 Answers

0
votes

This is what I was looking for, the exclude command has worked

wp_list_categories('orderby=name&show_count=1&exclude=66,67,68,69,70,71&title_li=');