Weird problem with pre_get_posts and $query->is_page()

pre_get_posts is innapropriate for this use, instead you should use the template_redirect filter, e.g.

add_action( 'template_redirect', funnction() {
    if ( ! is_user_logged_in() && is_page( 123 ) ) {
        wp_safe_redirect( home_url( '/sample-page' ) );
        exit;
    }
} );

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)