据我所知,你只需要改变if 在您的redirect_user() 功能到:
// List of Page slugs of the particular pages in question.
$pages = array( \'page-slug\', \'another-slug\', \'etc-etc\' );
// .. or specify a list of Page IDs: array( 1, 2, 3, ... )
// Redirect only if the current Page\'s slug (or ID) is within the above list.
if ( ! is_user_logged_in() && is_page( $pages ) ) {
wp_redirect( Login::url() );
exit;
}
但当然,通过;“第”页;,我猜你指的是一页,即
page 类型
如果情况并非如此,即您(也)在引用其他WordPress页面,如CPT和术语档案,那么您可以查看conditional tags here 只需使用与特定页面匹配的页面(is_page() 是这些条件标记之一)。但确切的条件/逻辑肯定取决于应该应用登录重定向的页面类型。
// Example..
if ( ! is_user_logged_in() && (
is_page( array( \'foo\', \'bar\', \'etc-slug\' ) ) || // check if it\'s one of the Pages
is_singular( \'my-cpt\' ) // or a if it\'s any single CPT pages
) ) {
wp_redirect( Login::url() );
exit;
}