最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Disable link for single posts

programmeradmin4浏览0评论

I'm working on a website where everything happens in the homepage. There you can see the posts in a list; but I don't want users to be able to browse the posts.

Is there a way to disable or block URLs for posts?

I'm working on a website where everything happens in the homepage. There you can see the posts in a list; but I don't want users to be able to browse the posts.

Is there a way to disable or block URLs for posts?

Share Improve this question asked Feb 7, 2022 at 14:43 AntaAnta 291 silver badge7 bronze badges 1
  • 1 You can remove the link in the theme template? Unless you're looking for a method that doesn't involve code? This is a programming stack though. Or are you asking how to prevent users directly visiting the URL if it's shared with them? – Tom J Nowell Commented Feb 7, 2022 at 15:29
Add a comment  | 

1 Answer 1

Reset to default 3
  1. you can either disable click events using CSS.

    .linkclass {     pointer-events: none;}
    
  2. Or better Modify the template and remove the part which creates anchor links for titles.

note: with the above, it is still possible to access the page by directly putting the full URL in the browser. if you want to completely remove the single page.

add_action('register_post_type_args', function ($args, $postType) {
    if ($postType !== 'post'){
        return $args;
    }

    $args['publicly_queryable'] = false;
  

    return $args;
}, 99, 2);

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论