For those looking for a solution to use WPShowposts as the display of the archive pages, including with custom post types, here is what I did:
I have 2 custom post types, each with their own custom taxonomies which I created in PODS. I set the archive to true for each.
CPT ‘event’ custom taxonomy ‘event_category’
CPT ‘client’ custom taxonomy ‘source’
1. Create a WP Show Posts list for each post type:
Post type: post Taxonomy: category
Post type: event Taxonomy: event_category
Post type: client Taxonomy: source
2. Copy the archive.php file to the generatepress-child folder
3. Replace the coding between do_action( ‘generate_archive_title’ ); and generate_content_nav( ‘nav-below’ ); with the following
$cat = get_queried_object(); $cat_slug = $cat->slug; $cat_tax = $cat->taxonomy; if ($cat_tax=='category'): $list = get_page_by_title( 'Simple', 'OBJECT', 'wp_show_posts' ); elseif ($cat_tax=='event_category'): $list = get_page_by_title( 'Simple-Event', 'OBJECT', 'wp_show_posts' ); elseif ($cat_tax=='source'): $list = get_page_by_title( 'Simple-Client', 'OBJECT', 'wp_show_posts' ); endif; wpsp_display( $list->ID, 'tax_term="' . $cat_slug . '"' );
1. I originally used is_post_type_archive() for testing if an archive of a custom post type, but it only evaluates as true if the archive is of the custom post type, and not for the associated taxonomies
2. get_category() returns an object, so you can get the slug value with the associated object or post, but for custom post types you use get_term() or get_the_terms() which returns an array, so you cannot get the slug value. I changed the code to get_queried_object() and it works for both custom post types and regular posts.
3. You need a different WP Show Post list for each different post type, which I missed for a while, even though it is obvious.
To minimize the coding further, you could remove the $list=get_page_by_title…. And just use the WPSP ID for each list, but I like being able to see which list is being used.
There is still a display issue with WPSP in archives with repeating post thumbnails which I will cover in another post.