1

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?

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
    Feb 7, 2022 at 15:29

1 Answer 1

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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.