• Hey guys,
    So, I’m working on users.opensciencegrid.org, and I’m a bit stuck. My boss wants the content in the <figcaption> tags out of the excerpts shown next to the images, and no matter what I do, I can’t seem to get it right. (to see the problem go to the research or news page) This is the code I have right now:

    <br />
    function bac_wp_strip_figcaption_tags_only( $excerpt ) {</p>
    <p>    $regex = '#(<figcaption>)\s*(\w*\s*)?\s*(</figcaption>)#';<br />
        $excerpt = preg_replace($regex,'', $excerpt);</p>
    <p>    return $excerpt;<br />
    }<br />
    add_filter( 'the_excerpt', 'bac_wp_strip_figcaption_tags_only', 0);<br />

    which is an edited version of this:

    <br />
    /***********************CODE-3**********************************************<br />
    * @Author: Boutros AbiChedid<br />
    * @Date:   April 18, 2012<br />
    * @Description: ONLY Remove header tags and their content from the Excerpt.<br />
    * DOES NOT modify anything else in the excerpt.<br />
    * @Tested on: WordPress version 3.3.1<br />
    ****************************************************************************/</p>
    <p>function bac_wp_strip_header_tags_only( $excerpt ) {</p>
    <p>    $regex = '#(<h([1-6])[^>]*>)\s?(.*)?\s?(<\/h\2>)#';<br />
        $excerpt = preg_replace($regex,'', $excerpt);</p>
    <p>    return $excerpt;<br />
    }<br />
    add_filter( 'the_excerpt', 'bac_wp_strip_header_tags_only', 0);<br />

    Anyone have a brilliant idea?

  • The topic ‘remove and content in the_excerpt’ is closed to new replies.