Skip Navigation

[Resolved] CPT (Types) with posts assigned returns Sorry, no content matched your criteria.

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 9 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 4 replies, has 2 voices.

Last updated by timothyS-3 9 years, 1 month ago.

Assisted by: Shane.

Author
Posts
#290557

I am trying to:
1. Create a custom post type. (I will be creating multiple CPTs)
2. Import posts from our current site. Categories and Tags remain attached.
3. Convert imported posts to my new CPT using the Convert Post Types plugin. Categories and Tags remain attached.
4. Created a View that displays list of CPT posts and inserted Views shortcode. View has clickable title and excerpt.

I visited this URL: /category/my-category-name/

I expected to see: Default archive for category called My Category Name.

Instead, I got: "Sorry, no content matched your criteria."

I have added code to my functions.php file that I found in the support forum, but made no difference. I seem to be having the very same issue with the Author archive.

I have found no discover-wp tutorial for dealing with CPT and relationships to WP archives.

#290774

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Timothy,

Thanks for contacting us.

Could you let me know which parts of this has been already achieved.

Were you able to map your imported CPT correctly?

#290907

Hi Shane,

I just got it all to work. I have a test CPT called "talk" and found some code on this forum that needed to be added to the functions.php file. I duplicated for my similar issues with Author and Tag archives and now all seems to be working.

Here's what I added. Do you see any issues with this? Anything else I should know about this topic/issue?

/* Add CPTs to Category archives */
function wpse_category_set_post_types( $query ){
if( $query->is_category ):
$query->set( 'post_type', array( 'post', 'talk' ) );
endif;
return $query;
}

add_action( 'pre_get_posts', 'wpse_category_set_post_types' );

/* Add CPTs to Author archives */
function wpse_author_set_post_types( $query ){
if( $query->is_author ):
$query->set( 'post_type', array( 'post', 'talk' ) );
endif;
return $query;
}

add_action( 'pre_get_posts', 'wpse_author_set_post_types' );

/* Add CPTs to Tag archives */
function wpse_tag_set_post_types( $query ){
if( $query->is_tag ):
$query->set( 'post_type', array( 'post', 'talk' ) );
endif;
return $query;
}

add_action( 'pre_get_posts', 'wpse_tag_set_post_types' );
#291148

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Timothy,

I'm not seeing any issues with the code.

Please mark the ticket as resolved if the issue is resolved.

If not please let me know and I will more than be happy to help out 🙂

#292035

Thank you.

The forum ‘Types Community Support’ is closed to new topics and replies.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.