Tag Info

New answers tagged

1

In the filter, you will need to find the post parent of $post, get the value of the custom field of parent post and then add that value to $post['post_excerpt'] (where the caption is stored): add_filter('attachment_fields_to_save', 'wpse_insert_custom_caption', 10, 2); function insert_custom_default_caption($post, $attachment) { //Check if the $post is ...


1

WordPress stores image (attachment) data as follows: Description: post_content field Caption: post_excerpt field Alt: _wp_attachment_image_alt meta value And in code, that translates to: // Description echo $post->post_content; // Raw the_content(); // Caption (description as fallback) the_excerpt(); // Caption (explicitly) echo ...



Top 50 recent answers are included