Support » Theme: OceanWP » HTML in image caption

  • When I try to insert HTML into the image caption it just displays the raw HTML, not the parsed HTML. I would like to insert an image credit into the caption with a link to the photographer but it isn’t working.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello,

    Try to switch to a different wordpress theme temporarily to check it works with other themes or not. If it works, then disable/enable plugin one by one to check for a possible conflict.

    @smc2935 Did you ever find a satisfactory resolution to this issue? I have the same problem, but I cannot access the plugins to test them, nor can I change the theme (not authorized). I’d be happy with a coding workaround if one exists.

    • This reply was modified 2 years, 3 months ago by lukeobritt.
    Thread Starter smc2935

    (@smc2935)

    No, I haven’t been able to get it fixed. I disabled all of my plugins, updated WordPress and the theme is the newest version but I still can’t display HTML in the featured image caption.

    At least I’m not alone. I have to do this without a plugin (not my site) so, for now, I have to be satisfied with adding the link to a line of text formatted to look like a caption. Thanks for getting back to me!

    Hello! I have the same problem.

    This is because $caption is escaped. For example in

    wp-content/themes/oceanwp/partials/single/media/blog-single.php

    	// Caption
    	if ( $caption ) { ?>
    		<div class="thumbnail-caption">
    			<?php echo esc_attr( $caption ); ?>
    		</div>
    	<?php
    	} ?>

    You can display HTML removing esc_attr

    However, direct editing theme files is not a recommended approach. A better way should be found 🙂

    Hello again!

    I opened an issue at https://github.com/oceanwp/oceanwp/issues/210

    Probably there will be an answer there.

    However it is more safe to use wp_kses_post( $caption )

    Regards

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘HTML in image caption’ is closed to new replies.