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
1 Answer
Reset to default 3you can either disable click events using CSS.
.linkclass { pointer-events: none;}
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);