You can add multiple compared condition variable in single if condition using logical OR operator.
For more knowledge of Logical condition click
function force_type_private($post)
{
if ($post['post_type'] == 'my_post_type1' || $post['post_type'] == 'my_post_type2') {
$post['post_status'] = 'private';
}
return $post;
}
add_filter('wp_insert_post_data', 'force_type_private ');
Related Posts:
- How do I require authorization / login to view a specific set of posts / pages?
- Set posts of a custom post type to be private by default?
- Fetching private posts or custom post types via WP-API with basic authentication
- Disable comments from showing up public for Custom Post Type
- Making a Custom Post type only visible to non-users via a specific link
- Comprehensively Restrict Post Type Taxonomy to Logged-in Users
- query private custom post type
- How do I display content to users who are not logged in instead of 404 on Private custom posts?
- Custom post type permalink returns 404 when set to private
- Have custom post type Visibility be private by default, and have radio button also set to “Private”
- Easiest way to have closed comments on a custom post type
- How can I incldue a “private” post type in a loop for public users?
- Adding custom post type archives to a WordPress menu
- Why does my custom taxonomy show a total count across all post types
- Custom post type save_post action not firing
- Redirect after deleting post and keep track of pagination
- Custom Post Type archive as front page
- How to auto send email when publishing a custom post type?
- Dynamic page.php template for custom post types
- Permalinks in Custom Post types
- how to create my own edit.php admin page code or template for my custom post type
- Custom Post Type with Nested Taxonomy and Template Files
- Disable WordPress Recognizing Path as Attachment
- Rest Api v2 orderby meta_key in custom post type
- Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?
- Display Custom Post Type in Recent Posts
- How to allow “Add New” capability of CPT when links to its UI are placed as a submenu?
- Parent / Child formatting in a list of post of a custom post type
- When ‘is_post_type_archive()’ return true?
- How to check if “is single” page
- How to display Custom Post Type Post based on Tag with Shortcode Parameter?
- Change custom taxonomy after certain time – CPT template
- Custom Taxonomy URL are redirecting to page with the same name
- Get posts from a custom post type by child categories of a parent category
- Want to Add Custom Fields for Uploading video to WordPress Users from front end
- Custom Posts Types as Custom Fields
- Hierarchical Custom Post Types in Array
- Making certain categories of CPT not publicly queryable
- WordPress Custom Post Type Navigation + Children
- custom post type and hidden url : what is the cleanest way to build CPT with custom page template?
- page menu entry for custom post type
- Exclude objects from WordPress API based from ACF field using rest_prepare_{$post_type}
- Custom taxonomies relationship
- Custom Permalink to remove category word , keeping posts permalink with date?
- How to remove post listing page for a custom post type
- How to include term custom meta into the custom taxonomy term permalink structure
- Setup template_redirect using has_term when NO term assigned
- search suggest – filter post type
- Custom Taxonomy not being saved on custom posttype
- Different Ways to Query Custom Post Types?
- Addin plugin custom post type to members plugin
- Custom Post Type Slick Slider “$ is not a function”
- Get parent category id from child category page for custom taxonomy
- Trying to get custom post of a custom taxonomy
- Remove custom permalink structure from custom post type without modifying register_post_type() directly
- Change Slug of a Custom Post Type
- How can I create an automatic drop down menu with my tags?
- show current item in custom menu, when inside a custom post type
- sort CPT on Custom Taxonomy Archive page
- Programmatically add custom field to post_name in a custom post type
- Best way to change the blog page post type?
- Multiple wp_editor instances in custom post type using Ajax
- Different categories for custom post type
- Safe to throw 404 error in request filter?
- Get single posts archive information
- Adding a Custom Field to be used by Posts 2 Posts
- If custom category search then page 2 not found
- Show the categories the current post has
- order the meta query results by 2 custom fields
- 404 error rewrite permalinks
- Pagination not working in custom post type. Help
- wp_insert_post from XML feed only inserting first post
- Does this archive template part look like its making too many calls to the db?
- Limiting the Number of User Posts to Their Own Posts
- add_action for save_post_{type} resulting in WSOD
- Filter posts by their related field’s custom field
- Issue removing columns from admin table
- How can I register multiple custom post fields to json?
- WP REST API Custom endpoint don’t work in my plugin
- Using meta boxes as the title of a custom post type
- How do I get all authors posts of a custom post type outside loop
- CPT/Taxonomy/Postname permalink structure makes pagination break
- Custom Taxonomy not working front side Woocommerce
- WordPress loop add heading before first of type
- Filterable portfolio in WordPress using jQuery isotope
- How do i create user accounts from custom posts that have email addresses
- How to hide editor, but keep media library access
- Best way to use Category & Custom Fields?
- Plugin Error on activating
- Custom posts affecting Recent Posts
- Advanced Custom Fields: single-books.php works, books.php does not
- Custom Taxonomy Showing in WP Menu
- Is it good practice to search for custom posts based on custom field values?
- Is it possible to create a separate page for custom posts gallery?
- Custom post type with custom fields enabled, is there a way to set a default group of fileds?
- URL Redirection From Custom Type to Posts
- Remove Permanent URL for custom post types
- How do I hide single category post on my post page
- Links in archive not including taxonomy parameter
- Get permalink in custom post type loop doesn’t work