Support » Fixing WordPress » Image Caption Being Pulled into Excerpt?

  • Hi,

    My website is I have a post in there, a review for a movie. On the single post page, i have two images. I added captions to them. For example, under one image i added “there’s tons of red symbolism in the film.”

    On my front page, I have thumbnails and excerpts of all my articles. On this particular post, the excerpt text is PULLING the image caption “there’s tons of red symbolism in the film” so literally when a person goes to my homepage and tries to read whatthe review is about, get a taste of it, first thing they read is “there’s tons of red symbolism.”

    I don’t want that to happen. How can I get the excerpt to not do that. Thanks.

Viewing 8 replies - 1 through 8 (of 8 total)
  • By default the excerpt shows the first 55 words it finds. You can enter the excerpt manually into the dialog box on the add/edit post screen if you don’t want it to do that.

    Damn I didn’t want to enter it manually, I have everything set up in my functions.php a certain way so it’ll look good. UGHHH. I found this, do you know anything about it?

    1. From what I understand the caption is a shortcode, so wrap get_the_content(…) inside strip_shortcodes() and it should remove it.

    2. You can always simply hide it with CSS. It’s not a perfect solution but may be sufficient for your case. CSS class of the caption paragraph is .wp-caption-text.

    I tried the second one, but i have to mess with it. I don’t really understand how to do #1.

    I have never done #1 but there is good info here and it seems pretty straightforward.

    With #2 you could use CSS to set visibility: hidden; for .wp-caption-text

    Hmm.. using codex, I added this:

    // Removes shortcodes from post excerpts
    function remove_shortcode_from_index($content) {
    if ( is_home() ) {
    $content = strip_shortcodes( $content );
    return $content;
    add_filter(‘the_content’, ‘remove_shortcode_from_index’); my functions.php file. Doesn’t seem to be removing anything though.. I also did #2, that didn’t work either.. but I didn’t remove the code from functions.php before I did it. They are both there together.

    Keep in mind that is_home will only work if the home page is the main blog page in Settings > Reading. If you have selected “a static page” you would have to use is_front-page

    Yes I don’t use a static page. _home should be ok to use. I wish the CSS thing would just work it would be much less complicated. But thank you for all your help.

    Also, Firebug & page source do not show that text as having any .wp-caption class.

    The reason you can’t do it with CSS is because that text is not being assigned a separate CSS class.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Image Caption Being Pulled into Excerpt?’ is closed to new replies.