Viewing 4 replies - 1 through 4 (of 4 total)
  • This is specifically answered in the FAQ.

    add_filter( 'restricted_site_access_is_restricted', 'my_rsa_feed_override’, 10, 2 );
    
    function my_rsa_feed_override( $is_restricted, $wp ) {
        // check query variables to see if this is the feed
        if ( ! empty( $wp->query_vars['feed'] ) ) {
            $is_restricted = false;
        }
        return $is_restricted;
    }

    You can use something like get_post() to get the current post, and add logic like “if the page ID equals” or “if the post_name is,” etc. If you just want to blacklist a certain page, you can use get_the_ID().

    Hi @hendridm

    Thanks for this reply.

    Could you write the code we must add to exclude specific pages, please ?
    I’m not a specialist.

    And where must I add this code ?
    Into the function.php file ?

    Thanks for your help
    Regards
    Ludovic

    Hi @vinayakboga8

    You have the same request like me.
    I’m not a specialist.

    Could you give me the code you finally use to exclude a specific page ?

    BIG Thanks
    Regards
    Ludovic

    Hi @renaisens and @vinayakboga8 ,

    Maybe this can help you:

    add_filter( 'restricted_site_access_is_restricted', 'exclude_page_from_restriced_access', 10, 2 );
    
    function exclude_page_from_restriced_access( $is_restricted, $wp ) {
    	$url = 'https://' . $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ];
    	$current_post_id = url_to_postid( $url );
        if ( $current_post_id  == '644' ) {
            $is_restricted = false;
        }
        return $is_restricted;
    }

    In my case I had to exclude a page with ID 644. You have to put this code in functions.php. It maybe is a quick and dirty solution, but it works for me.

    Regards Will

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Exclude Specific Page’ is closed to new replies.