• Resolved solosimar

    (@solosimar)


    Hi!
    I looking for a testimonials slider in my homepage and your plugin seems great! However, I do not want to have individual pages for each testimonial, which I believe can be accomplished by hiding this content post type from search results.
    Something like this, added to my child theme functions.php:

    function modify_testimonials() {
        if ( post_type_exists( 'testimonial' ) ) {
    
            global $wp_post_types, $wp_rewrite;
            $wp_post_types['testimonial']->exclude_from_search = true;
        }
    }
    add_action( 'init', 'modify_testimonials', 1 );

    However, I do not know the name of this post_type (testimonial doesn’t work)… Could anyone help me?
    Many thanks!

    http://wordpress.org/plugins/easy-testimonials/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor richardgabriel

    (@richardgabriel)

    Hey solosimar!

    You have the post type right (testimonial) — are you sure the above code is what you need to do?

    I can look into adding this as an option inside the plugin, in a future release.

    Thanks!
    Richard

    Thread Starter solosimar

    (@solosimar)

    Hi, Richard!
    I got the code from wordpress.stackexchange.com and adapted to my needs. I tested it with a custom post type and even with WP core pages and it worked… that’s why I thought I wasn’t getting the name right 🙂

    Thread Starter solosimar

    (@solosimar)

    Hi,
    Just to let you know I figured out how to accomplish this, using a tip I found here http://www.webtipblog.com/modify-wordpress-custom-post-type-configuration-registered/:

    // functions.php
    
    add_action( 'init', 'updateSidebarsPostType', 99 );
    
    /**
    * updateSidebarsPostType
    *
    * @author  Joe Sexton <joe@webtipblog.com>
    */
    function updateSidebarsPostType() {
        global $wp_post_types, $wp_rewrite;
    
        if ( post_type_exists( 'multiple-sidebars' ) ) {
    
            // exclude from search results
            $wp_post_types['multiple-sidebars']->exclude_from_search = true;
        }
    }

    Thread Starter solosimar

    (@solosimar)

    (marking the topic as resolved 🙂 )

    Plugin Contributor richardgabriel

    (@richardgabriel)

    Thanks, both for sharing your solution and marking the topic resolved!

    I hope anyone else with the same question finds the above info helpful.

    Best,
    Richard

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

The topic ‘How to exclude testimonials from search?’ is closed to new replies.