[Support request] Exclude redirected pages from page search results

Home Forums Support [Support request] Exclude redirected pages from page search results

Home Forums Support Exclude redirected pages from page search results

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #925650
    Olga

    Hello,

    Is there a way to exclude redirected pages from the page search results (when the user uses the search icon on the website)

    Best,
    Olga

    #925784
    David
    Staff
    Customer Support

    Hi there,

    are you using a plugin for your redirections?

    #925997
    Olga

    Yes, Redirection.

    #926095
    David
    Staff
    Customer Support

    May need to speak with the plugin author, but i would assume its using a custom post type, so you could filter the search results for only posts and pages with this PHP snippet:

    add_action('pre_get_posts','search_filter');
    function search_filter( $query ) {
      if ( ! is_admin() && $query->is_main_query() ) {
        if ( $query->is_search) {
          $query->set('post_type', array('post', 'page') );
        }
      }
    }
    #928038
    Olga

    Thank you, the snipped does not work though.

    #928053
    David
    Staff
    Customer Support

    Would you be able to ask the Redirect plugin author?
    If they can’t help hiding it from the search results, they should be able to tell us what the name of the post template is.

    #928062
    Olga

    ok, I sent a form, let’s hope they answer. Thank you!

    #928084
    David
    Staff
    Customer Support

    Keep us posted – if you don’t hear back soon let us know

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.