Support » Fixing WordPress » wp_list_categories for custom post_type

  • Resolved sibweber


    Hi everybody,

    Hope somebody can help me with this. I’m still a relative newbie so this might be a silly question but I’ve searched up and down and couldn’t find a solution for this particular example.

    I have registered a custom post_type called ‘organisation’ and registered the default ‘category’ taxonomy for it, as I want it to share the same categories with the default posts.

    Now I want to create a page that lists certain categories but when you click on any of them, display only posts of type ‘organisation’. When I use wp_list_categories, I only get posts of the default post type.

    Here is what I’ve got:

    $post_type		= 'organisation';
    $taxonomy		= 'category';
    $orderby			= 'ASC';
    $show_count		= 0;
    $hide_empty		= 0;
    $pad_counts		= 0;
    $hierarchical	        = 1;
    $exclude			= '55';
    $title				= '';
    	$args = array(
    		'post_type'		=> $post_type,
    		'taxonomy'		=> $taxonomy,
    		'orderby'			=> $orderby,
    		'show_count'		=> $show_count,
    		'hide_empty'		=> $hide_empty,
    		'pad_counts'		=> $pad_counts,
    		'hierarchical'	        => $hierarchical,
    		'exclude'			=> $exclude,
    		'title_li'			=> $title
    <?php wp_list_categories( $args ); ?>

    What do I have to do to make WP display posts with my custom post type?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thanks Laura, that’s more or less exactly the code but I am using.

    Apologies if I’ve been unclear, but I am not trying to display a list of custom taxonomies. I am trying to output a list of the default categories (which does work using the above code) that displays posts of my custom post type.

    I have registered the default ‘category’ taxonomy for my custom post type with this function:

    function share_categories() {
      register_taxonomy_for_object_type('category', 'organisation');
    add_action( 'init', 'share_categories');

    But when I display a list of categories and click on any of them, only posts of type ‘post’ will be displayed. Posts of my custom post type ‘organisation’ will not.

    Hey 🙂

    I’m not quite clear what exactly you’re trying to do here, sorry – but it seems you’ll need to query for your post type more specifically.

    Have a look at this thread here – that might help?


    I eventually managed to solve the problem by going to the permalink settings in the admin panel and just clicking save w/o changing anything.

    Somebody had suggested to do that (‘flush the permalinks’) for a slightly different problem and it worked.

    I can’t believe I wasted an entire day on this.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wp_list_categories for custom post_type’ is closed to new replies.