WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. krimsly
    Member
    Posted 4 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?

    Thanks,

    NorthK

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    Can you post a link to a page demonstrating this?

  3. doc4
    Member
    Posted 4 years ago #

    krimsly,

    Show the code used to generate the caption beforehand.

  4. krimsly
    Member
    Posted 4 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...

    Thanks

    NorthK

    http://wordpress.org/support/topic/320635?replies=1#post-1245050

  5. krimsly
    Member
    Posted 4 years ago #

  6. methodagile
    Member
    Posted 4 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