WordPress.org

Ready to get started?Download WordPress

Forums

Still no way to add italics to captions? (5 posts)

  1. sc456a
    Member
    Posted 2 years ago #

    Off and on for years I've needed to be able to add italics to captions. I still haven't found a solution. Here is what I have found:

    -You can add italics to the entire caption via CSS, but that's not ideal because only part of the caption should be italicized and the CSS code only lets you italicize the entire caption.
    -You can manually code the image, caption and drop-shadow box and produce the desired effect, but that requires hand-coding every image.

    Therefore, no ideal solution is available. It seems absurd to me that after years of requesting this "feature" WordPress still doesn't allow code in the caption field. Unless I'm missing something?

  2. zimmi88
    Member
    Posted 2 years ago #

    Hmm... looks like there's no luck italicizing the text in the WYSIWYG editor. Probably the best way around this is coming up with some sort of custom syntax to denote italicized text in your caption that's plain text friendly (not HTML tags).

    This thread talks about a similar problem with links. It looks like the popular solution there is to use jQuery to parse the page for custom tags and replace that text with the proper HTML tag.

    My gut says there has to be some sort of WordPress hook that would allow a WordPress plugin to parse caption text before it's outputted to the screen, but I haven't been so lucky in finding such a hook yet. But, theoretically, should a hook exist, it would be a matter of creating a plugin that ties into that hook and does a find-replace on the custom tags.

    I hope this helps!

  3. sc456a
    Member
    Posted 2 years ago #

    Thanks for the tip, Zimmi. I was able to use some code from that post and make things work. Here is the code to be inserted in your footer file:

    <script type="text/javascript">
    (function($){
    	$(function() {
    		$("p.wp-caption-text").each(function() {
    			var $caption = $(this).text();
    			$(this).html($caption);
    		});
    	});
    });
    </script>

    That will allow WordPress to parse HTML in captions, but it seems you have to use the HTML editor in WordPress because the visual editor still strips it. Better than nothing, though.

    WordPress - please give us the ability to use HTML code in captions natively. There are years of posts of people asking for this.

  4. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    HTML in captions is on the agenda for the next WP, 3.4, which should be out mid-April (ish)

  5. sc456a
    Member
    Posted 2 years ago #

    Actually this isn't working because the visual editor strips the HTML code from the captions or just jumbles it all up and breaks it altogether. Does anyone else have a solution?

Topic Closed

This topic has been closed to new replies.

About this Topic