Support » Developing with WordPress » Disabling single blog posts (but keep archive)

  • I have full length blog posts displayed on my homepage, and I don’ want any single blog post pages since they are unnecessary in my case. Ho can I completely disable these? I am not talking about removing the title link, since the single posts could still be reached when their respective url is typed into the browser. I want to disable them completely. I tried this

    add_action('register_post_type_args', function ($args, $postType) {
    if ($postType !== 'post'){
        return $args;
    }
    
    $args['publicly_queryable'] = false;
    return $args;
    }, 99, 2);

    but it does not work…

    Thanks for your help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @barb55

    I believe that setting publicly_queryable to false will only work for Custom post types, not the default WordPress post type.

    I did a quick search and found a solution that could potentially work for what you have described. https://wordpress.stackexchange.com/questions/128636/how-to-disable-the-single-view-for-a-custom-post-type

    I have not tested the code but it seems that 301 redirecting all singular posts for the post post-type might be a reasonable solution.

    Thread Starter barb55

    (@barb55)

    @daisyo thanks, I tried using that redirection snippet but it is not working either…I am thinking: I actually don’t need all the other blog features like date, author, categories etc – but simply adding all the content to the homepage would not be a good idea since the content would increase over time and make the page very slow (and not ave good usability either). Is there maybe alternatively a way to add pagination to my home page?

    If using posts is not an absolute requirement then maybe the Page Break block might work for your needs. https://wordpress.org/support/article/page-break-block/

    Thread Starter barb55

    (@barb55)

    @daisyo Tank you! This is exactly what I need! One question though: do you know where to translate the “Pages:”? And maybe add a navigation arrow? I looked in the po-file from WP and also found the string(at least it said Pages:), but when I changed it and uploaded the updated po- and mo-files, nothing was changed…

    Is your intention to translate to a language other than English or change the style of the pagination but keep the text in English?

    Thread Starter barb55

    (@barb55)

    @daisyo well, actually both 😉 I found out that I can change the wording through my theme’s po-file. But additionally, it would be great to not have ALL pages shown since I would have a lot of pages in the pagination. Do you know how to limit them to let’s say 3 and then have “…” and then te last page so you can click through? Linke this.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.