I am hoping to be able to have the [caption] shortcode automatically get inserted into the post content area when you add in an image that has the caption field filled in. I believe this is supposed to be the default functionality in WordPress. Is there anything I need to declare in the functions.php file to make this work in my custom theme though?


1 Answer 1


Did a bit more digging and it appears to have been a conflict in my theme:

add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_width_attribute', 10 );
function remove_width_attribute( $html ) {
  $html = preg_replace( '/(width|height)="\d*"\s/', "", $html );
  return $html;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.