Forums

Stripping out [caption] tags? (4 posts)

  1. pigsandbees
    Member
    Posted 1 year ago #

    I've changed my homepage from the_content to the_excerpt to show only a synopsis of the articles on the first page. I've also installed the the_excerpt_reloaded plugin to allow my images to be included in these synopses.

    The problem I now have is that the-excerpt-reloaded seems to fall over when encountering wordpress's [caption] tags around images. The code appears as text in the post rather than being interpreted as it should be.

    Is there a way so strip out or ignore these tags in my excerpts (ignoring anything in [] brackets would be fantastic if that's possible?

    The other alternative of course, would be if there's another way to display images in my excerpts other than the_excerpt_reloaded.

    Any help greatly appreciated...
    Cheers

  2. cabraham
    Member
    Posted 1 year ago #

    I solved this by adding this:

    // get rid of the [caption]s
    $text = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $text );

    around L102 of the-excerpt-reloaded.php, before the line if($excerpt_length < 0) {

    Chris

  3. marco.casieri
    Member
    Posted 10 months ago #

    Cool...

    This is the most useful think that I founded for the excerpt function.
    Can you explain it just for understand it more well?

    PS.: I place it on L129/131 replacing $text with $output

    Marco

  4. gbert1
    Member
    Posted 9 months ago #

    cabraham 's code also works finely with wp-limit-posts-automatically.php

    (wp-limit-posts-automatically.php is an excerpt tool to limit automatically posts without more tag)

Topic Closed

This topic has been closed to new replies.

About this Topic