Custom Post Types and Category Archives

Community Forums Forums Design Tips and Tricks Custom Post Types and Category Archives

This topic is: resolved

This topic contains 2 replies, has 3 voices, and was last updated by  01themas 1 year, 1 month ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #40708

    SaraGraybill
    Participant
    Post count: 16

    I have created a custom post type for my website listing the services available.  I am using categories for the custom post type and I can’t seem to figure out how to show the service cpt in the category archive.  It just says no posts match your criteria.  Any ideas?

    http://www.cobbengr.com/civilservants/
    #40797

    braddalton
    Participant
    Post count: 8857

    Just noticed your footer links not working.

    I think you may have setup your custom post types incorrectly but hard to say from here. I may be wrong.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #46843

    01themas
    Participant
    Post count: 1

    Try something like this to be able to have categories  displayed across all CPTs:

    //enables categories to be used across different post types
    add_filter(‘pre_get_posts’, ‘query_post_type’);
    function query_post_type($query) {
    if(is_category() || is_tag() || is_home() && empty( $query->query_vars['suppress_filters'] ) ) {
    $post_type = get_query_var(‘post_type’);
    if($post_type)
    $post_type = $post_type;
    else
    $post_type = array(‘post’,’business’, ‘academic’, ‘partners’, ‘people’, ‘facilities’,’programs’ ,’nav_menu_item’);
    $query->set(‘post_type’,$post_type);
    return $query;
    }
    }

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.