• 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

Sorry, no content matched your criteria after creating custom post type

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 › General Discussion › Sorry, no content matched your criteria after creating custom post type

This topic is: resolved
  • This topic has 5 replies, 2 voices, and was last updated 7 years, 1 month ago by iefdelaender.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • December 26, 2015 at 10:50 am #174834
    iefdelaender
    Member

    Hello,

    I use the modern studio pro theme.

    I'm trying to make a custom post type but I've get an error "Sorry, no content matched your criteria" when I click to a category or tag. I filled in a category or tag when I input new content into the custom posts. I see that in my table that a category or tag is associated.

    This is my code:

    <?php
    /*
    Plugin Name: Waterlelie Custom Post Type
    Plugin URI: http://wpbeaches.com/create-custom-post-types-in-genesis-child-theme-in-wordpress/
    Description: Custom Post Waterlelies database
    Author:
    Version:1
    Author URI:
    */

    /*
    This code is a plugin to create a Custom Post Type in WordPress, it can be used with any WordPress theme.
    The action initialises the function below it.
    This example uses the term 'Events' as its name, a search and replace will allow any name to be used, making sure plural and singular versions of the name are replaced.
    Also replace the name in 'rewrite' and in the 'register_post_type' function.
    For non-Genesis themes the 'genesis-cpt-archives-settings' can be removed from the supports array.
    To activate this as a plugin just add to wp-contents/plugins and activate in Dashboard
    */

    function create_custom_post_type() {

    $labels = array(
    'name' => __( 'Waterlelies' ),
    'singular_name' => __( 'Waterlelies' ),
    'all_items' => __( 'All Waterlelies' ),
    'add_new' => _x( 'Add new Waterlelie', 'Waterlelies' ),
    'add_new_item' => __( 'Add new Waterlelie' ),
    'edit_item' => __( 'Edit Waterlelie' ),
    'new_item' => __( 'New Waterlelie' ),
    'view_item' => __( 'View Waterlelie' ),
    'search_items' => __( 'Search in Waterlelie' ),
    'not_found' => __( 'No Waterlelies found' ),
    'not_found_in_trash' => __( 'No Waterlelies found in trash' ),
    'parent_item_colon' => ''
    );
    $args = array(
    'labels' => $labels,
    'public' => true,
    'has_archive' => true,
    'menu_icon' => 'dashicons-admin-users',
    'rewrite' => array( 'slug' => 'waterlelies' ),
    'taxonomies' => array( 'category', 'post_tag' ),
    'hierarchical' => true,
    'query_var' => true,
    'menu_position' => 5,
    'supports' => array( 'genesis-cpt-archives-settings', 'thumbnail' , 'custom-fields', 'excerpt', 'comments', 'title', 'editor')
    );
    register_post_type( 'Waterlelies', $args );
    }

    add_action( 'init', 'create_custom_post_type' );

    //flush the permalinks - ref - https://codex.wordpress.org/Function_Reference/register_post_type#Flushing_Rewrite_on_Activation

    function my_rewrite_flush() {
    // First, we "add" the custom post type via the above written function.
    // Note: "add" is written with quotes, as CPTs don't get added to the DB,
    // They are only referenced in the post_type column with a post entry,
    // when you add a post of this CPT.
    create_custom_post_type();

    // ATTENTION: This is *only* done during plugin activation hook in this example!
    // You should *NEVER EVER* do this on every page load!!
    flush_rewrite_rules();
    }
    register_activation_hook( __FILE__, 'my_rewrite_flush' );

    December 26, 2015 at 10:54 am #174835
    Brad Dalton
    Participant

    You can use this code to add a custom post type via your functions file.

    After adding the code, re-save your permalinks.


    Get Help – Book Consultation.

    December 27, 2015 at 4:32 am #174859
    iefdelaender
    Member

    It didn't work. Still get the message "no content matched" I used the code in the link you give me. I tried an other theme 'genesis sample theme and I deactivated all my plugins and re-saved the permalinks but nothing works.

    December 27, 2015 at 7:33 am #174862
    Brad Dalton
    Participant

    Link to the CPT archive please.


    Get Help – Book Consultation.

    December 28, 2015 at 6:08 am #174940
    iefdelaender
    Member

    this is the archive and when you click on a tag or category you will see the no content matched message

    http://www.pondlibrarytestdrive.org/waterlelies/

    December 28, 2015 at 9:23 am #174946
    iefdelaender
    Member

    I've found the solution of this problem:
    https://wpbeaches.com/show-custom-post-types-category-archive-page/

    function themeprefix_show_cpt_archives( $query ) {
     if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
     $query->set( 'post_type', array(
     'post', 'nav_menu_item', 'custom-post-type-name'
     ));
     return $query;
     }
    }
    add_filter( 'pre_get_posts', 'themeprefix_show_cpt_archives' );
  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Sorry, no content matched your criteria after creating custom post type’ is closed to new replies.

CTA

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

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 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