Title: Category and custom posts issues
Last modified: August 30, 2016

---

# Category and custom posts issues

 *  Resolved [mikegrattan](https://wordpress.org/support/users/mikegrattan/)
 * (@mikegrattan)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/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 [http://pmppals.net/listing-type/surgeon/](http://pmppals.net/listing-type/surgeon/).
   If I use the above code to allow the Testimonials category to be navigated, it
   stops navigation to [http://pmppals.net/listing-type/surgeon/](http://pmppals.net/listing-type/surgeon/).
 * Please advise.
 * [https://wordpress.org/plugins/testimonials-widget/](https://wordpress.org/plugins/testimonials-widget/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Subharanjan](https://wordpress.org/support/users/subharanjan/)
 * (@subharanjan)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/category-and-custom-posts-issues/#post-6621734)
 * Hi Mike,
 * I am sorry about the troubles.
 * Is your custom post type linked to same taxonomy `Category` ?
 * Can you please try the code below instead of the above code snippet you have 
   tried. Its using the `is_post_type_archive()`.
    **Code: **
 *     ```
       add_filter( 'pre_get_posts', 'pre_get_posts_allow_testimonials' );
       function pre_get_posts_allow_testimonials( $query ) {
       	if ( $query->is_admin ) {
       		return $query;
       	} else if ( ( $query->is_main_query() || is_feed() ) && ! is_page() && ( ( ! empty( $query->query_vars['post_type'] ) && 'post' == $query->query_vars['post_type'] ) || is_post_type_archive( array(
       				'post',
       				'testimonials-widget'
       			) ) )
       	) {
       		$query->set( 'post_type', array( 'post', 'testimonials-widget' ) );
       	}
   
       	return $query;
       }
       ```
   
 * Please let me know if it helps. Thanks !!
 *  Thread Starter [mikegrattan](https://wordpress.org/support/users/mikegrattan/)
 * (@mikegrattan)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/category-and-custom-posts-issues/#post-6621735)
 * Thanks for the reply Subharanjan. Since posting my question, I found another 
   Testimonials plug-in that is working for me. I appreciate your reply, but I will
   be using the other plug-in since it is working without having to add any supplemental
   code.
 *  Plugin Author [Subharanjan](https://wordpress.org/support/users/subharanjan/)
 * (@subharanjan)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/category-and-custom-posts-issues/#post-6621775)
 * Thanks for letting us know about the above. I’m sorry that the plugin didn’t 
   work as well as you needed it to.
 * Thanks,
    Subh

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Category and custom posts issues’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/testimonials-widget_c56561.svg)
 * [Testimonials Widget](https://wordpress.org/plugins/testimonials-widget/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/testimonials-widget/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/testimonials-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/testimonials-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/testimonials-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/testimonials-widget/reviews/)

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)

 * 3 replies
 * 2 participants
 * Last reply from: [Subharanjan](https://wordpress.org/support/users/subharanjan/)
 * Last activity: [10 years, 7 months ago](https://wordpress.org/support/topic/category-and-custom-posts-issues/#post-6621775)
 * Status: resolved