Maybe try the following:
function set_robotsmeta_default( $post_object ) {
if (!isset($post_object->robotsmeta) || $post_object->robotsmeta == "") {
$post_object->robotsmeta = "noindex,nofollow";
}
return $post_object;
}
add_action( 'the_post', 'set_robotsmeta_default' );
EDIT: Since the above didn’t work, the code below may work, by editing the global $post object before the plugin add_meta_boxes
is called. I just don’t know if this will affect posts that already have that value set.
function set_robotsmeta_default() {
global $post;
if (!isset($post->robotsmeta) || $post->robotsmeta == "") {
$post->robotsmeta = "noindex,nofollow";
}
}
add_action( 'add_meta_boxes', 'set_robotsmeta_default', 1);
Related Posts:
- How often do you need to register_post_type?
- How to register custom post types in a plugin?
- wordpress post_where set only for my costum post type
- Custom Fields as Post Type Options
- How to Debug the ‘save_post’ Action?
- How to add a button to custom post type’s posts-page
- How to hook into the CPT’s title placeholder?
- flush_rewrite_rules on save_post Does Not Work on First Post Save
- post_type_link filter causes 404 on the CPT page it’s used on
- Separating Search Results By Post Type
- List events by month
- Date query for a custom meta field
- remove_action conditionally for Custom Post Type
- Change plugin’s has_archive = true to false?
- Query posts between two dates (custom meta keys) CMB2
- Used with meta_query in query_posts works slowly
- Change upload_dir folder at a certain cpt but cant change back
- Creating a function that receives the taxonomy terms that have been changed in a custom post type
- Remove “Get Shortlink” button in admin of custom post type
- How to have the right design for a custom post type without accessing themes
- Set a default category – if the user didn’t select one- before creating a post
- Set object terms not working on plugin activation
- How to add the post ID (or any other post data) to a Contact Form 7 mail?
- Modifying date filter on admin page for custom post type to link to custom field
- how to add extra meta box or textarea into custom post types
- How to quickly reorder posts in the admin panel that will persist for the wp-api
- Validate custom fields before save using WordPress Rest API
- Update menu when saving settings
- How to retain $_POST data when submitting form to custom page
- Why get_posts() not returning only selected category posts from Custom Post Type?
- If post has custom field then display css-class
- Replace text in post from cvs
- Tracking changes in admin-page so user gets warning when leaving the page
- custom post type and non-standard gallery
- Make a custom_post translatable
- How to change permalink to include custom post type
- How to Add multiple instance of meta box to custom post type
- Adding custom image sizes and post types to a plugin or to a theme?
- Is there any way to get list of all possible filter hooks for all post types?
- Show all tags on custom post type
- How to hook WP initialization without modifying functions.php
- Add categories to a page with out using Custom Post Types
- Use remove_meta_box conditionally on custom post type
- ACF in wordpress
- post_parent in custom post type
- How do I amend form data before it is saved for a custom post type
- Pods CMS: How to add custom column to Adnvanced Content Type
- How to use template_include hook with form submission?
- How check if a post is saved from backend or frontend?
- How To Post WordPress Custom Post Types to Twitter via IFTTT
- Custom post type’s posts are not showing anywere but in xml sitemap
- WordPress hook which triggers on post import
- Unable to format dates to put in event calendar
- Filter content in shortcode
- Get image from external URL
- Getting only one post per category
- Update Post Status On Woocommerce Payment Complete
- Modify Posts from Custom_Post_Type within the plugin
- Create a simple Testimonial page
- Custom post type in Custom widget – $listItem
- Creating alternate meta box context locations
- Custom Plugin – Query CPT – Display Results
- Custom post type archive – error in nav-menu-template.php
- Is there a hook similar to “save_post” which only fires AFTER the post is completely published?
- Plugin Development using classes – Public & Private Callbacks
- Store a value in global scope after init hook is fired
- Dynamic page for nav items used as filters
- Accessing download link from the loop with WP Download Manager Pro
- Hook create / update post
- Reading Custom Post data so I can have user update Manually
- Custom Post Type Front Page Gives 404
- Show Post columns to specific users on condition
- Disable ‘Add New’ in custom post that is made from CPT UI
- Custom Post Type single post type shown in theme single.php
- Default custom post type url
- Run query on specific admin options page and send results to select field in another function
- call a function when insert and update a custom post type
- Create Inclusions and exclusions
- Populate metabox dropdown with post title from another Custom Post Type (issues with wp_reset / global $post)
- How to display all custom fields associated with a post type – IN THE ADMIN AREA?
- Display subcategories in the filter on CPT
- Understanding the workflow of form creation plugin
- Adding CPT changes entire layout of my site except for the archive of that CPT
- Use Custom Post Type as Storage Container Without Registering It
- next/prev post link by relationship post 2 post
- do action inside a class is not working
- Hook only specific post type
- Add Excerpt On Quicksand Plugin
- Author profile comments system
- Custom Post Types in plugins?
- Plugins for putting Custom Post Types into the Menu
- Plugin – read post into blank page [duplicate]
- How to hide home title on pages and posts?
- WP_Query is getting the post but the_post() not rendering any Post
- make playlist from a custom post type
- Custom Post Type to Plugin
- add comments custom fields after user is logged in
- Woocommerce product page is not showing custom css [closed]
- Simple Share Buttons Add Plugin and Custom Post Type
- WP 4.4 upgrade custom post type cannot add new