WordPress.org

Ready to get started?Download WordPress

Forums

Image caption in WP 2.6 (22 posts)

  1. Anonymous
    Unregistered
    Posted 6 years ago #

    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

  2. Anonymous
    Unregistered
    Posted 6 years ago #

    so..no ideeas?

  3. Pete
    Member
    Posted 6 years ago #

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

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

  4. Zack Katz
    Member
    Posted 6 years ago #

  5. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    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);
  6. JeanPaulH
    Member
    Posted 6 years ago #

    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.

  7. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

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

  8. JeanPaulH
    Member
    Posted 6 years ago #

    Thanks Otto. Unfortunately, WP still inserts the caption code in the post and (after saving) in the preview :-(

  9. Ciro Urdaneta
    Member
    Posted 6 years ago #

    I found here a simplier way :D

  10. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    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.

  11. alisonn
    Member
    Posted 6 years ago #

    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?

  12. Anonymous
    Unregistered
    Posted 5 years ago #

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

  13. Anonymous
    Unregistered
    Posted 5 years ago #

    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

  14. Ciro Urdaneta
    Member
    Posted 5 years ago #

    the function doesn't work anymore on WP 2.6.1 :(
    Parse error: syntax error, unexpected '}'...

    Could you please update it
    Regards
    Ciro

  15. Jauhari
    Member
    Posted 5 years ago #

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

  16. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

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

  17. klugefest
    Member
    Posted 5 years ago #

    Otto,

    Regarding your last post here, where in the Functions.php file are we supposed to put it? I'm really not that familiar with php.

    I tried just placing it somewhere and it didn't fix the captions. Oh, I'm running 2.6.3. Does that make a difference?

    Thanks in advance,
    Tim

  18. zonk675
    Member
    Posted 5 years ago #

    Thx Otto...works perfect (so far..heheh)

    @klugefest: Anywhere before the final ?>

    peace,
    zOnk

  19. john_nyc
    Member
    Posted 5 years ago #

    I used the add_filter('disable_captions', create_function('$a','return true;')); in my theme function file and the captions do not show on the home page, but they still show on the single post page. How can I disable them on the single page also????

  20. john_nyc
    Member
    Posted 5 years ago #

    still no luck - my theme's functions.php
    <?php
    if ( function_exists('register_sidebar') )
    register_sidebar(array(
    'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-inner">',
    'after_widget' => '</div></div>',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>',
    ));
    add_filter('disable_captions', create_function('$a', 'return true;'));
    ?>
    I am still getting captions though - any help? version 2.8

  21. john_nyc
    Member
    Posted 5 years ago #

    actually let me clarify -- full size image has no caption - thumbnails do -- should these be disabled the same way?

  22. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    The captions on gallery thumbnails can be hidden by CSS:
    .gallery-caption { display:none; }

Topic Closed

This topic has been closed to new replies.

About this Topic