• Resolved phlow

    (@phlow)


    Hello, first of all thank you for your plugin. It works.

    Today, I found out, if I use the built-in search from WordPress, that pages for members are showing up. To be precise an excerpt is showing up.

    Is there a way to filter out automatically pages protected by Simple WordPress Membership?

    For now, I used this in my functions.php to filter out pages. Short explanation of the code ? It filters by parent. All children from the parent page won’t show up in the search results.

    //Exclude specific posts and pages from WordPress Search
    function ss_search_filter( $query ) {
        if ( !$query->is_admin && $query->is_search && $query->is_main_query() ) {
            $query->set( 'post_parent__not_in', array( 1519 ) );
        }
    }
    add_action( 'pre_get_posts', 'ss_search_filter' );
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Pages for Members are showing up in Search Results – at least the excerpt’ is closed to new replies.