Support » Fixing WordPress » Image caption in WP 2.6

  • Is there an way to disable the image caption in WP 2.6 not showing under the actual image? I always add caption to my images(for alt tags) but I hate when the caption goes under the pic. How one can disable that?

    Tnx

Viewing 15 replies - 1 through 15 (of 21 total)
  • so..no ideeas?

    no it can’t… it’s becoming/going to become quite an annoyance I think.

    read more here
    http://wordpress.org/support/topic/189135

    Zack Katz

    (@katzwebdesign)

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Just add this to your theme’s functions.php file:

    function no_caption($deprecated, $attr, $content) { return $content };
    add_filter('img_caption_shortcode', 'no_caption', 10, 3);

    Hi Otto,
    Your code seems to throw errors when added to my theme’s functions.php (Cleaker 2 theme)
    Parse error: parse error, unexpected '}' in /var/www/vhosts/example.com/httpdocs/wp-content/themes/Cleaker2/functions.php on line 10

    The only other code in functions.php is for the widgetized sidebar.

    I tried several modifications of your code block, but it either gives me other errors or the caption is still inserted. Any help would be kindly appreciated.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Whoops. Add a ; after the return $content bit.

    Thanks Otto. Unfortunately, WP still inserts the caption code in the post and (after saving) in the preview πŸ™

    I found here a simplier way πŸ˜€

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    You should not use the CAPTIONS_OFF, as that post says. Read it closer. The captions will turn themselves back on at some future point when you upgrade if you do it that way.

    I’ve added the no_caption function (which works, thanks) but this means that the align class disappears along with it.

    Any ideas for keeping the align class with the image rather than the caption?

    after applying this to the functions.php file, the caption is still inserted under the pictures

    it worked now, if I add any caption, it won’t appear under the photo…but 2 new problems, the alignment is screwed and the picture still doesn’t have any alt tag

    the function doesn’t work anymore on WP 2.6.1 πŸ™
    Parse error: syntax error, unexpected ‘}’…

    Could you please update it
    Regards
    Ciro

    Can anybody show me the best solutions without HACK WordPress code?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    One line for 2.6.2 and up:
    add_filter('disable_captions', create_function('$a','return true;'));

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Image caption in WP 2.6’ is closed to new replies.