WordPress.org

Ready to get started?Download WordPress

Forums

Remove Caption Shortcode from the_content_rss ... ? (6 posts)

  1. chazbeaner
    Member
    Posted 4 years ago #

    Anyone know how to strip the caption shortcode from the_content_rss output? HTML markup for the img itself gets stripped, but the caption shortcode remains...

    I have tried strip_shortcode, remove_shortcode, remove_all_shortcode but to no avail.

  2. husklynet
    Member
    Posted 4 years ago #

    I am also in need for a solution to this problem. I have an XML-file a partner needs to use, but I can't seem to get rid of the [caption]-part of posts with images in them.

    Does this require some preg_replace or something? If so, can anyone point me in the direction of a solution?

  3. careybradfield
    Member
    Posted 4 years ago #

    this was posted somewhere else:

    add to the feed.php file

    $content = apply_filters('the_content_rss', $content); /* already was there, here is for navigation. it's near 164 line */
    $content = preg_replace("/\[caption.*\[\/caption\]/", '', $content); /* string itself */
    if ( $cut && !$encode_html ) /* next line, for navigation too */

  4. Joyful Thiek
    Member
    Posted 4 years ago #

    I'm having the same problem. And I'd like to try the code given above too, but only thing is I can't find a feed.php. Help anyone?

  5. kestrel_id
    Member
    Posted 4 years ago #

    @craybradfield Thanks for the Regex solution you posted it works a treat.

    I had to use the Regex after I found the the WP Codex function strip_shortcodes function leaves the closing shortcode tag for some unknown reason [/caption]

    Has anyone else come across this and perhaps have a theory as why this is happening?

  6. joneslee85
    Member
    Posted 4 years ago #

    @kestrel_id: I confirmed this, I have to do a str_replace("[/caption]", '', $content) to get rid of this. This could be a bug. Can someone confirm?

Topic Closed

This topic has been closed to new replies.

About this Topic