[resolved] Image caption shortcode not being parsed (6 posts)

  1. krimsly
    Posted 6 years ago #

    Greetings all.

    When I insert an image into a post and give it a caption, WordPress generates a shortcode that looks like this:

    [caption id="attachment_55" align="alignleft" width="127" caption="Here is my caption"]<img class="size-full wp-image-55 " title="my image title" src="my-url/my-image.jpg" alt="my caption text" width="127" height="163" />[/caption]

    Unfortunately, WordPress is not parsing the shortcode into HTML so the shortcode gets stuck as-is in the HTML. I'm not using any plug-ins so I don't think it is a plug-in incompatibility.

    Does anyone have any ideas on this?



  2. esmi
    Forum Moderator
    Posted 6 years ago #

    Can you post a link to a page demonstrating this?

  3. doc4
    Posted 6 years ago #


    Show the code used to generate the caption beforehand.

  4. krimsly
    Posted 6 years ago #

    Hello all. Thanks for reading. It turns out the problem is because some WP functions call apply_filters() and some do not. The functions I was using in my theme (for example get_the_content()) did not so the short codes were not getting parsed. I needed to add this:

    $content = get_the_content();
    $content = apply_filters('the_content', $content);

    However, that begs the question, what will happen to my theme in the future if the WP core adds the apply_filters() call to one of the functions I'm using-- there would be duplicate calls to apply_filter(). Please see my new post on this below for more info...




  5. krimsly
    Posted 6 years ago #

  6. methodagile
    Posted 5 years ago #

    I'm getting the same problem, but only on post pages not listings. Go here for an example: http://www.bearingsguide.com/20091113/flasks/

Topic Closed

This topic has been closed to new replies.

About this Topic