Custom Fields
Re-Envisioned
Support MB Custom Post Type Make CPT Private by default

  • Creator
    Topic
  • #32632
    shmaltz
    Participant

    Is it possible to make an entire CPT (all posts and archive) "Private"?

    I only want these posts/archive visible on the frontend by the admin/editors, and for all others, I want it to show a 404, just like a standard private post does.

    Is this possible?

    Thanks

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #32657
    Long Nguyen
    Moderator

    Hi,

    You can use a custom code to set the post status to private when creating/updating a post. For example

    function force_type_private( $post ) {
        if ($post['post_type'] == 'my_post_type')
        $post['post_status'] = 'private';
        return $post;
    }
    add_filter( 'wp_insert_post_data', 'force_type_private' );

    https://wordpress.org/support/article/post-status/

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