Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Chris Dillon

    (@cdillon27)

    Hi Phil,

    Until I can build this option into the plugin, here are some methods.

    1. A plugin like Search Exclude to exclude individual testimonials.

    2. Restrict the search query to posts and pages only by adding this to your theme’s functions.php:

    /**
     * Exclude testimonials from search results.
     */
    function my_search_filter( $query ) {
      if ( !$query->is_admin && $query->is_search ) {
        $query->set( 'post_type', array( 'post', 'page' ) );
      }
      return $query;
    }
    add_filter( 'pre_get_posts', 'my_search_filter' );

    3. Modify the plugin. Edit strong-testimonials.php and find this section:

    $testimonial_args = array(
    			'labels'                => $testimonial_labels,
    			'singular_label'        => _x( 'testimonial', 'post type singular label', 'strong-testimonials' ),
    			'public'                => true,
    			'show_ui'               => true,
    			'capability_type'       => 'post',
    			'hierarchical'          => false,	 // @since 1.8
    			'rewrite'               => array( 'slug' => _x( 'testimonial', 'slug', 'strong-testimonials' ) ), // @since 1.8
    			'menu_icon'             => 'dashicons-editor-quote',
    			'menu_position'         => 20,
    			'exclude_from_search' 	=> false,  // @since 1.15.10
    			'supports'              => array( 'title', 'excerpt', 'editor', 'thumbnail', 'custom-fields', 'page-attributes' )
    	);

    Change exclude_from_search from false to true.

    Thread Starter stones001

    (@stones001)

    Hi Chris,
    The third one do the trick ??
    Thanks so much for your precious time

    All my best from France,
    Phil

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘avoid testimonials in search pages’ is closed to new replies.