Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers 3

up vote 0 down vote accepted

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

UPDATE

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

share|improve this answer
    
I mean i have post with the image and some text, then i show it on front page. Unfortunately it shows text from caption as first. I need caption so i can't just delete it. Is there any code to make query and show posts on frontpage without caption? –  Marcin Oct 22 '12 at 19:08
    
edited the answer –  Mridul Aggarwal Oct 22 '12 at 19:32
add comment

Here is an example below where you can embed html tags within the Caption box and it will style your caption text accordingly. enter image description here

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.

share|improve this answer
    
Thanks, but how to edit caption without html? I've got to enable it to some people not too good in coding. Any plugin or code to edit captions in regular admin panel/ writing posts? –  Marcin Oct 22 '12 at 19:06
add comment

Solved. I added: "if ( is_home() ) add_filter('img_caption_shortcode', create_function('$a, $b, $c', 'return $c;'), 10, 3);"

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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