I have 2 questions for caption for images: - how to edti them with bold, italics and so on? I do it, but it doesn't work. - if the image is first, how to exclude caption from excerpt in query especially for frontpage?
I have 2 questions for caption for images: - how to edti them with bold, italics and so on? I do it, but it doesn't work. - if the image is first, how to exclude caption from excerpt in query especially for frontpage?
For your first question- HTML support for captions was a new feature in wordpress 3.4, if you have any version prior to that, it won't work
I'm not sure if i understood your 2nd question, but to exclude the caption from not displaying on the page, you'll have to either delete the caption from the image or edit your theme's template files
First if the image was inserted in the page content, it is inserted in the form of a shortcode, so you can use the filter img_caption_shortcode
to override the default shortcode output.
If it's set as featured image, instead of using the_post_thumbnail
, use get_post_thumbnail_id
& generate the img
tag yourself & skip the caption.
Next to permanently disable the captions functionality(you already cleared you don't want to do that), you can use this add_filter( 'disable_captions', '__return_true' );
If you want a WYSIWYG editor in captions, there isn't any hook for that. You'll have to code it yourself
Here is an example below where you can embed html tags within the Caption box and it will style your caption text accordingly.
Also, don't forget that WordPress applies a default class of wp-caption
to your caption elements for which you can further use to specify custom CSS properties, so technically you can wrap text within your caption box also using <span class="special-class">
tags with special classes and give them unique styling.
Solved. I added: "if ( is_home() ) add_filter('img_caption_shortcode', create_function('$a, $b, $c', 'return $c;'), 10, 3);"