I found an adequate solution.
Generally, I used the save_post_{$post->post_type}
hook which gave me a $post_ID
and a $post
object.
I was just checking to see if there was a thumbnail and if is not there to add it. That is all.
add_action( 'save_post_book', function ($post_ID, $post){
if ( get_post_meta($post_ID, '_thumbnail_id', true) ) :
return;
endif;
if($thumbnail_id = get_option('my_default_thumbnail_id', false)) {
add_post_meta($post_ID, '_thumbnail_id', $thumbnail_id);
}
}, 10, 2);
Related Posts:
- Using add_theme_support inside a plugin
- How to add multiple featured image in meta box in post editor?
- How to List Thumbnails based on Custom Categories
- Where to put my code: plugin or functions.php?
- Should I use custom post types or a custom database tables for plugin development?
- How come Featured Image isn’t showing up in my Custom Post Type?
- add_image_size() for specific Post Types
- Creating an Image-Centric Custom Post Type?
- Where, When, & How to Properly Flush Rewrite Rules Within the Scope of a Plugin?
- How do I change the author of a custom post type?
- Submit post and upload image from front-end
- How to disable generation of default image sizes for some custom post types?
- Custom Post Type Plugin: Where Do I Put The Template?
- Correctly delete posts with meta and attachments [duplicate]
- Best way to flush_rewrite_rules for custom post type, in a mu-plugins plugin?
- How to Add Custom Taxonomy To Woocommerce Plugin
- Creating a Custom Post Type as a Plugin? Why?
- Custom user role cannot see or modify featured image
- Make featured image required
- Quick edit screen customization
- Mini-Site Strategy
- The Great Plugin Nomenclature Contest of 2011
- Prevent trash/delete action on specific post types
- How to remove “featured image” functionality from a custom post type?
- Attaching media to custom posts without editor
- How to add custom content template part for a custom post type on main query using a plugin
- How to completely disable a taxonomy archive on the frontend?
- get attachments for all posts of particular post type
- Featured Image Panel Missing From Custom Post Type in WordPress 3.2
- How do you create an archive for a custom post type from a plugin?
- List most recent image uploads, but only for specific custom post type
- How to add a button to custom post type’s posts-page
- set_post_thumbnail_size in percent, not pixels?
- Loading custom page template via plugin
- Why The Init Hook For Custom Post Types
- How to set a fall back template for a custom post type in a plugin?
- Best way to filter featured image text for a custom post type?
- How to add multiple images to custom post type?
- Creating a custom public user page
- wordpress plugin error handling
- How to get term link that crosses different custom post types?
- register_taxonomy with multiple object type and update_count_callback
- Redirect after deleting post and keep track of pagination
- How often do you need to register_post_type?
- wp_generate_attachment_metadata gives me an empty array
- get_edit_post_link() not working as expected when passed id in plugin
- If featured image doesn’t exist, show post content
- Add custom field to media attachment image attribute in post editor
- Where to put archive-{post-type}.php
- Render a different post/template from within the template_include action?
- Is flush_rewrite_rules necessary when creating a custom post type? Why?
- How to use a dedicated template for the Custom Post Type from a plugin?
- How do I Make a custom post type get a custom post template in a plugin
- set and unset the custom field value
- Determine which template-{slug}.php is being loaded
- How I upload, save and set a featured image from my frontend?
- How to append text to title of Custom Post Type post (without affecting all titles on page)?
- Remove Slug from Custom Post Type results in 404
- WordPress metabox file upload in custom post [duplicate]
- working Custom Post Type and Widget code no longer works when moved from functions.php to plugin
- Count all images of a certain post type
- How do you modify the ‘post_parent’ of a custom post type?
- WordPress custom post action hook
- Unable to filter on field on edit.php page
- Trouble adding custom featured image for custom taxonomy TERMS
- Multiple Permalinks for custom post type post
- On clicking on the category name the page is redirecting on 404 pge
- Insert slider (Custom Post Type) into pages
- How do I create a custom post type for a training CMS in WordPress?
- WP Query group/order by category name
- Stopping WordPress from Auto Generating Image Files for Sizes
- Save or update data when custom post published
- How can i place Feature Image under title field in wp-admin?
- Remove POST_TYPE from custom post type permalink
- Uploaded image not appearing in custom post type
- How to remove thumbnail sizes for specific post type on a child theme?
- Featured image metabox not showing up
- Do attachments added to custom post types have a post parent?
- image srcset returns false
- Custom Taxonomy and tax_query Issue?
- How to use different featured image size for a custom post type?
- Use a textarea for a custom post type
- Using posts and postmeta table to store custom Address Book Plugin data
- How to register custom post types in a plugin?
- Actions that Run on Admin Edit Page Load After Posts Are Queried
- get_the_post_thumbnail() returning empty string on custom post type
- Change admin post thumbnail size for custom post type only
- Row actions not showing? Why?
- Make custom post type display as a page
- template_redirect not working, apparently for no reason
- How to: add option to add more checkboxes on custom post type
- Custom role capabilities to administrator not taking effect (no plugin)
- How do I add a custom button to my “edit” list? ( edit.php?post_type= ) beside “Add New”
- How to add notification in the sidebar of the administration panel when a Custom post type is created? [duplicate]
- Hierarchical or Non-hierarchical Custom Post Type in Real World Example
- how to set default value for checkbox in wordpress
- How to append element after thumbnail
- How do I include drag-and-drop in a plugin?
- Return Attachments from Custom Post Type
- How to get attached file in wordpress from custom post