• Resolved DeveloperWil

    (@developerwil)


    Archived posts show up in the default WordPress site search

    https://example.com/?s=keyword

    You could add a bit of code to remove archived from the search

    function wb_search_filter_archived( $query ) {
        if ( ! is_admin() && $query->is_main_query() ) {
            // Not a query for an admin page.
            // It's the main query for a front end page of your site.
                $query->set( 'post_status', array( 'publish' ) );
            }
        }
    add_action( 'pre_get_posts', 'wb_search_filter_archived');
Viewing 1 replies (of 1 total)
  • Plugin Author shawfactor

    (@shawfactor)

    Yes, but that should only be the case if archived content is publicly available.

    This is a deliberate decision. I understand some may not want it that way. But as you demonstrate it is easily fixed with a code snippet. I am a believer in decisions not options so I won’t add an option to change this for now but I will add a similar code snippet to the plugin docs

    I am resolving this as this for good order but will still monitor the thread

Viewing 1 replies (of 1 total)
  • The topic ‘Archived Post Shows Up In Site Search’ is closed to new replies.