Category and custom posts issues
-
My first problem was that the category I created, “Testimonials”, could not be navigated to. I also could not navigate to the default “testimonial” stub used by the plug-in. I searched the forum and found the following code to paste into functions.php:
add_filter( ‘pre_get_posts’, ‘pre_get_posts_allow_testimonials’ );
function pre_get_posts_allow_testimonials( $query ) {
if ( $query->is_admin ) {
return $query;
} elseif ( ( $query->is_main_query() || is_feed() )
&& ! is_page()
&& ( ( ! empty( $query->query_vars[‘post_type’] ) && ‘post’ == $query->query_vars[‘post_type’] )
|| is_archive() )
) {
$query->set( ‘post_type’, array( ‘post’, ‘testimonials-widget’ ) );
}return $query;
}This allowed me to navigate by category, but it also stopped another custom post type from working. I’m using a custom post type called a “Listing” and I have a listing of “Surgeon” set up at https://pmppals.net/listing-type/surgeon/. If I use the above code to allow the Testimonials category to be navigated, it stops navigation to https://pmppals.net/listing-type/surgeon/.
Please advise.
- The topic ‘Category and custom posts issues’ is closed to new replies.