Basically I'm looking to share the same featured image across multiple sub pages under their respective primary page.
Is there any plugin that lets me do this, so they can inherit a featured image?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityYou could easily do this by hooking into the save_post action and updating the featured image custom field. In your functions.php file, add the following code:
function interit_featured_image( $post_id ) {
// Get Parent ID
$parent_id = wp_get_post_parent_id( $post_id );
// Only proceed if this page has a parent
if ($parent_id != 0) :
// Get Parent Thumbnail
$parent_thumbnail = get_post_meta( $parent_id, '_thumbnail_id', true );
// Get Parent Caption Data (for the other plugin)
$parent_caption = get_post_meta( $parent_id, '_cc_featured_image_caption', true );
// Set Thumbnail
update_post_meta( $post_id, '_thumbnail_id', $parent_thumbnail );
// Set Caption (again, for the other plugin)
update_post_meta( $post_id, '_cc_featured_image_caption', $parent_caption );
endif;
}
add_action( 'save_post', 'interit_featured_image' );