我有一个体育比赛网站。我可以创建未来比赛的日历,然后将帖子状态设置为“私人”。
用户 不是 登录后可以点击帖子并访问它。
如何禁用未登录用户的帖子链接?
将此代码放入函数中。php文件。
function getPrivatePostMatch() { global $post; $status = get_post_status( $post->ID ); if( $status == "private" ) { wp_redirect( home_url() ); // you can add your page url here exit; } } add_action('template_redirect','getPrivatePostMatch');