Custom post type not showing up in archive page

Posted in: Newspaper
Post count: 23

I have a custom post type ‘my-custom-post-type’. When I go to mydomainname.com/my-custom-post-type, the archive page shows up, but the posts on the page are incorrect.

In Newspaper functions.php, I tried two solutions:

1) https://thomasgriffin.com/how-to-include-custom-post-types-in-wordpress-archive-pages/
2) function custom_post_type_archive( $query ) {
if ( $query->is_category() && $query->is_main_query() ) {
$query->set( ‘post_type’, array( ‘post’, ‘my-custom-post-type’ ) );
}
}
add_action( ‘pre_get_posts’, ‘custom_post_type_archive’ );

Do you have any pointers/suggestions on how I can see the correct posts on the archive page? Thank you

Post count: 35449

Hi,
First you should check if that CPT have the archive mode enabled – https://i.imgur.com/2Ayw9Rh.png after that you can use the cloud templates too add a template for your CPT archive – https://i.imgur.com/pHElmVt.png
I hope this will help you!

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newspaper’ is closed to new topics and replies.