function default_comments_on( $data )
{
$myCustomPostType = array("my_custom_post_type_1", "my_custom_post_type_2", "contacts"); /* Custom Post Type Array */
if (in_array($data['post_type'], $myCustomPostType))
{
$data['comment_status'] = 'open';
}
return $data;
}
add_filter( 'wp_insert_post_data', 'default_comments_on' );
Add this code in functions.php
Related Posts:
- Cleaning up WordPress to improve performance?
- List of all theme customizer control types?
- Modify previous and next text from pagination links
- How can I modify the permalink via a filter?
- Shortcode putting html such as
- Calling a method from functions.php on a click of a button
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- How to change featured content to a different tag in WordPress Twenty Fourteen?
- How do I create comment-reply-button using element not
- WordPress menu deletes when trying to add a hook
- Overriding a theme redux file in child theme
- Validate a users email address when using gmail to register
- Output a WooCommerce product custom field in WooCommerce using get_post_meta()
- How to check If Oembed is empty or not
- Making Quote Plugin more efficient
- Can’t load WP function into external function
- allow subscribers to see private posts without plug in
- Image as Sales Badge
- How to Arrange PHP Files to Allow for Multiple Types of Pages?
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- Show css depending on activity type in BuddyPress activity-loop [closed]
- remove wp floating submenu in wp dashboard
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- Fatal error: Uncaught Error: Call to undefined function test()
- Return a numerical function value in Customizer controls
- How can I get the values of my WordPress $wpdb query in Jquery?
- Css loads very slow [closed]
- Show when user is online/offline in real time on user_profile.php
- theme_root returning a truncated URI
- Call to undefined function get_userdata() in plugin
- Echo string and function?
- how to test for all children (including multilevel grand-childern) of page
- Dilemma of Populating all the categories in a drop down list
- Add item to top of menu using a filter in functions.php
- Adding wrapper elements in the_date() like in the_title()?
- Notify users only on post publish
- Plugin Generate Unexpected output during activation
- Limit Taxonomy Output in Conditional Statement
- wp_redirect only works on main site and not on other sites
- require_once() if a product in woocommerce contains a tag [closed]
- PHP code for displaying WordPress posts in a static page not working
- Shortcode for Listing Users from Meta Value?
- Display css ONLY on most recent post of specific category?
- How to add data to a custom field at the wp_users table?
- How to remove the space before the ellipsis in excerpt?
- How can I use custom menus with a Bootstrap WordPress theme?
- How to make a cookie be on the whole site instead of being on a specific page/
- Child Theme’s Read More Text
- call a string/function from database
- Adding an Unlinked Space in a Custom Function
- Get date function not working
- How do I call an external php non WordPress class into functions.php?
- How to remove/hide collapse menu for user/subscriber?
- How to implement __() function in my theme’s php file?
- A function to get the content of a page
- How a HTML form can trigger a PHP function?
- Allow a user or role to view drafts and previews, but not other admin privileges?
- WP custom posts: filter results to custom taxonomy tag that corresponds to user meta field
- Get current user id in function php
- Proper way to remove html code on child theme
- Trying to add Custom Post Type to this functions.php command
- Apply function.php filter only if url not has /amp/
- Preventing direct access to a page in WordPress
- Get custom field value from the function.php
- Non-blocking file_put_contents in function.php
- Display a custom name when the user has no name settle in his account
- Advance custom fields variable with if statement & Function
- Restrict wordpress access to logged users only
- Discount in the specific product title using keyword ( Woocoommerce )
- Modify post image in full size
- How to link all featured images to custom url in single.php for only non-logged-in users?
- Woocommerce Add custom “Add to cart button” in single page with tags
- Hook into all password resets in WordPress and get password before hashing?
- Populate Posts based on category selected using AJAX that means without page refresh
- remove_action() not working in page template – Genesis
- How to sort (orderby) a query done by a template function before the ‘foreach’ loop?
- Can’t get_users info by using json_encode
- Dropdown menu on custom menu
- What is wrong in this code?
- How can the searchform.php know if it’s used on a registered sidebar id ‘sidebar-1’ or ‘sidebar-2’?
- Page returning ID from array, how to return the correct values for post in acf wordpress
- WordPress get_post_meta issue
- Woocommerce Price Text
- Modify php code to pass a page id as a parameter in order to create a breadcrumb
- Show custom default avatar instead of gravatar
- Removing all my hardcoded URLs with get_site_url()
- WordPress 2014 Theme – Featured Content with multiple tags?
- Highlight main menu when on specific posts or pages
- ajax form function error
- Display custom meta box in my template file
- Woocommerce – Shipping tax class based on cart items not using the highest tax available
- How to display the date under the post title?
- Simple Probléme in wordpress
- Contact form with dynamic dropdown and filter
- Critical Error customiser
- Dynamic Email Handler with ‘header (“Location: …’
- WooCommerce: write featured image dimensions to custom fields in product’
- Generate and upload screenshot as featured image for user-submitted post
- transition_post_status hook, works – but not if the post is new
- Custom plugin doesn’t show in admin menu – when code added, displays an empty page