• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Custom Post Types and Category Archives

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

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

This topic is: resolved

Tagged: category archives, CPT, genesis.2.1.2

  • This topic has 7 replies, 4 voices, and was last updated 11 years, 2 months ago by cbryant.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • May 13, 2013 at 1:33 pm #40708
    SaraGraybill
    Member

    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?


    Graybill Creative | Twitter

    http://www.cobbengr.com/civilservants/
    May 13, 2013 at 7:50 pm #40797
    Brad Dalton
    Participant

    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.


    Tutorials for StudioPress Themes.

    June 19, 2013 at 9:37 pm #46843
    01themas
    Member

    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;
    }
    }

    September 23, 2014 at 1:04 pm #125458
    cbryant
    Member

    I'm running into the same problem described by SaraGraybill.

    I've set up a CPT called "sermon".
    Set it up manually in my functions.php. (code at bottom).
    The CPT itself correctly uses the Genesis 2.0 Archive template support for CPTs.
    That is: I can view a complete list of all CPTs on an Archive page, and add info to it using Genesis Archive settings. All good.

    However, this CPT has "categories" enabled.
    Yet, when I click on the "Filed under 'Category Name' on a single CPT it brings me to the standard Genesis Category Page (good) but gives me the error "Sorry, no content matched your criteria."

    The category heading and title which I added in the backend do appear correctly on the category page.
    So... it's as if it's seeing the Category correctly - but not seeing the CPTs within the category .

    @ 01themas idea seemed to make sense. But I had no success with it.

    Is there a simple Genesis function for adding Genesis Category Archive Support to CPT Categories (and not just to the Post Type)?

    Any suggestions are welcomed.

    I'm working locally so have no link to provide.

    Here is my CPT registration code... in case maybe anyone spots a glaring omission on my part....

    Thanks in advance for any thoughts or comments.

    Chris

    add_action('init', 'register_cpt_sermon');
    	function register_cpt_sermon() {
    		register_post_type('sermon', array(
    			'label' => 'Sermons',
    			'description' => 'Audio Recordings of Sermons',
    			'public' => true,
    			'show_ui' => true,
    			'show_in_menu' => true,
    			'capability_type' => 'post',
    			'map_meta_cap' => true,
    			'hierarchical' => true,
    			'rewrite' => array('slug' => 'sermon', 'with_front' => 1),
    			'query_var' => true,
    			'has_archive' => true,
    			'menu_position' => '5',
    			'supports' => array('title','editor','excerpt','custom-fields','revisions','thumbnail','author','page-attributes','genesis-cpt-archives-settings'),
    			'taxonomies' => array('category'),
    			'labels' => array (
    				  'name' => 'Sermons',
    				  'singular_name' => 'Sermon',
    				  'menu_name' => 'Sermons',
    				  'add_new' => 'Add Sermon',
     /*I've included a full series of labels - but left them out for readability here*/
    			)
    		) ); 
    	}
    September 23, 2014 at 1:16 pm #125460
    Brad Dalton
    Participant

    Where did you get the code for the CPT?


    Tutorials for StudioPress Themes.

    September 23, 2014 at 1:21 pm #125461
    Brad Dalton
    Participant

    This is what i use http://wpsites.net/web-design/add-support-for-creating-custom-taxonomies-to-existing-portfolio-custom-post-type/

    However, i also use this for the CPT http://wpsites.net/web-design/add-custom-post-type/


    Tutorials for StudioPress Themes.

    September 23, 2014 at 3:05 pm #125478
    cbryant
    Member

    Hi Brad,

    Thank you for responding.

    The code was generated by Custom Post Types UI plugin.

    I'm going to take a look at your recommendations and links and will post the results.

    Thanks again - Chris

    September 23, 2014 at 3:45 pm #125481
    cbryant
    Member

    This code snippet did the trick:

    //* Show Sermon CPT entries in addition to Posts in Category Archive Pages 
    add_action( 'pre_get_posts', 'cpt_entries_and_posts_in_archives' );
    function cpt_entries_and_posts_in_archives( $query ) {
     
    	if ( $query->is_main_query() && !is_admin() && is_category() ) {
    	$query->set( 'post_type', array( 'post', 'sermon' ) );
    	}
    }

    (props Bill Erickson)


    @Brad
    - thanks for your input. Your wpsites is a valuable resource!

  • Author
    Posts
Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble