0

I included a category in my Menu. When I click the category in my menu, nothing shows up of this categorie. I expected that at least one published post of a custom post type shows up.

My custom post type has the link:

mysite.com/customPostTypeName/PostTitle

My category site has the link:

mysite.com/category/testCategorie

I would like to show in the menu a link which displays all posts and custom post types of a certain category.

Any suggestions what I am doing wrong?

I appreciate your replies!

UPDATE

My post type looks like the following:

add_action( 'init', 'cptui_register_my_cpts_matratze' );
function cptui_register_my_cpts_matratze() {
    $labels = array(
        "name" => __( 'Matratzen', '' ),
        "singular_name" => __( 'Matratze', '' ),
        );

    $args = array(
        "label" => __( 'Matratzen', '' ),
        "labels" => $labels,
        "description" => "",
        "public" => true,
        "publicly_queryable" => true,
        "show_ui" => true,
        "show_in_rest" => false,
        "rest_base" => "",
        "has_archive" => true,
        "show_in_menu" => true,
                "exclude_from_search" => false,
        "capability_type" => "post",
        "map_meta_cap" => true,
        "hierarchical" => false,
        "rewrite" => array( "slug" => "matratze", "with_front" => true ),
        "query_var" => true,

        "supports" => array( "title", "editor", "thumbnail", "excerpt", "trackbacks", "custom-fields", "comments", "revisions", "author", "page-attributes", "post-formats" ),      
        "taxonomies" => array( "category", "post_tag" ),
            );
    register_post_type( "matratze", $args );

// End of cptui_register_my_cpts_matratze()
}

I haven`t registered any Taxonomie.

  • Make sure that it is set to "public" so that it is publicly queryable, and that you activate has_archive (I'm not sure if the last one is required but it's worth a shot). Otherwise you will need to write a custom tax query for your category template, in which you include all the post types you want to show. – Pim Sep 26 '16 at 20:41
1

It's showing blank because there are no posts in it. The default category taxonomy is only connected with the default post type. To enable it to use it with a custom post type, add the following line to the register_post_type configuration

'taxonomies'  => array( 'category' ),

For more info : https://codex.wordpress.org/Function_Reference/register_post_type#taxonomies

  • I am using CPT UI plugin. Any suggestions how to manage it there? I appreciate your reply! – Kare Sep 27 '16 at 5:49
  • I have no idea about that plugin so it would be better to ask that to the support of that plugin. – Patrick S Sep 30 '16 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.