• Nate

    (@northern-virginia-homes-advice)


    I’m using shortcode to pull in IDX data to my site. I need some of what the shortcode pulls in but some html/text I don’t want. So I’m trying to strip is out with a function, not java, I want it gone before the search engines read it.

    Here’s the code: I want this whole string gone from the start of the <p class=”dsidx-summary”> to the end </p>

    <p class=”dsidx-summary”>
    See all <a href=”/idx/city/vienna/?idx-q-ListingStatuses=3&idx-d-
    SortOrders<0>-Column=DateAdded&idx-d-SortOrders<0>-
    Direction=DESC”>Real estate in the city of Vienna.

    (all data current as of
    6/19/2014)
    </p>

    Been tearing my hair out trying to get this to work.

Viewing 1 replies (of 1 total)
  • The preg_replace() below should work:

    $t = <<<EOTXT
    <h1>a header</h1>
    <p class="some-class">leading paragraph text</p>
    <p class="dsidx-summary">
    See all <a href="/idx/city/vienna/?idx-q-ListingStatuses=3&idx-d-
    SortOrders<0>-Column=DateAdded&idx-d-SortOrders<0>-
    Direction=DESC">Real estate in the city of Vienna.
    
    (all data current as of
    6/19/2014)
    </p>
    <p>another paragraph</p>
    EOTXT;
    
    echo htmlentities($t) . '<br />';
    echo '=========<br />';
    
    $t2 = preg_replace('/<p class="dsidx-summary">.*?<\/p>/s', '', $t);
    
    echo htmlentities($t2) . '<br />';
Viewing 1 replies (of 1 total)
  • The topic ‘Need to strip html from part of a shortcode output’ is closed to new replies.