• Here’s my issue:

    I have assigned a custom post type to certain categories, but those categories don’t appear to be registered to anything on the site. For example, if I go directly to the category url, it returns a category not found page. If I assign a normal post type to the same exact category, I can enter the url directly and find those posts.

    Basically, I am trying to enable a user to search by category, but categories that are assigned to only a custom post type are not appearing. For that matter, even if I type in the direct url of the category, it takes me to an error page: “Sorry, we can’t find the category you’re looking for at this URL. Please try selecting a menu item from above or to the side of this message to get where you…”

    I thought I got everything in my custom post type code, but I must have missed something. Any help would be appreciated:

    ‘add_action(‘init’, ‘create_trainingplan_post_type’);

    function create_trainingplan_post_type() {
    register_post_type(‘trainingplan’, array(
    ‘labels’ => array(
    ‘name’ => ‘Training Plans’,
    ‘singular_name’ => ‘Training Plan’,
    ‘add_new’ => ‘Add New Training Plan’,
    ‘add_new_item’ => ‘Add New Training Plan’,
    ‘edit’ => ‘Edit Training Plans’,
    ‘edit_item’ => ‘Edit Training Plan’,
    ‘new_item’ => ‘New Training Plan’,
    ‘view_item’ => ‘View Training Plans’,
    ‘search_items’ => ‘Search Training Plans’,
    ‘not_found’ => ‘No Training Plans found’,
    ‘not_found_in_trash’ => ‘No Training Plans found in Trash’
    ),
    ‘public’ => true,
    ‘exclude_from_search’=> false,
    ‘rewrite’ => array(‘slug’ => ‘my-custom-training-plan’, ‘with_front’ => true),
    ‘supports’ => array(
    ‘title’,
    ‘excerpt’,
    ‘title’,
    ‘excerpt’,
    ‘editor’,
    ‘custom-fields’,
    ‘revisions’,
    ‘thumbnail’,
    ‘author’,
    ‘page-attributes’

    ),
    ‘taxonomies’ => array(‘category’, ‘post_tag’) // this is IMPORTANT
    ));
    flush_rewrite_rules();
    }

  • The topic ‘Categories assigned to custom post type not found’ is closed to new replies.