Viewing 4 replies - 1 through 4 (of 4 total)
  • Do you need the Quick Redirects filtered out or just the ones set up on the individual page/posts?

    The latter it easier to do, and would be done differently than the Quick Redirects – both would have to use a hook to filter the search results.

    Regards,
    Don

    Thread Starter webheadcoder

    (@webheadllc)

    just the ones that I setup on each individual post/page.

    Ok – you can add this to your functions.php file (or child functions.php file if using child themes) anywhere after the opening <?php tag:

    add_action( 'pre_get_posts', 'stop_redirect_in_search_filter', 99 );
    function stop_redirect_in_search_filter($query) {
    	if ( !is_admin() && $query->is_main_query() ) {
    		if ($query->is_search)
    			$query->set('meta_query', array('relation' => 'AND', array('key' => '_pprredirect_active','value' => '1', 'compare' => 'NOT EXISTS')));
    	}
    }

    That should stop anything that has the ‘active’ box checked for an individual redirect from showing in the search results.

    Warm regards,
    Don

    Thread Starter webheadcoder

    (@webheadllc)

    awesome, thanks! works perfectly!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Exclude redirected page from search results’ is closed to new replies.