Support » Themes and Templates » Truncate "the_content" to an element.

  • Resolved jlan2747

    (@jlan2747)


    Example:
    Heres the_content so far:

    <object width="560" height="315">
    				<param name="movie" value="http://www.youtube.com/v/JaQtWg6bifw?fs=1"></param>
    				<param name="allowFullScreen" value="true"></param>
    				<embed src="http://www.youtube.com/v/JaQtWg6bifw?fs=1&rel=0" type="application/x-shockwave-flash" width="560" height="315" allowfullscreen="true"></embed>
    				</object>
    <img alt="The Atheist Experience Episode #766: Viewer Calls" src="http://www.axpweekly.com/wp-content/uploads/2012/06/20180_the_atheist_experience_default.jpg" />
    Episode #766: Viewer Calls WEBSITE: www.axpweekly.com

    I want to truncate to just the object:

    <object width="560" height="315">
    				<param name="movie" value="http://www.youtube.com/v/JaQtWg6bifw?fs=1"></param>
    				<param name="allowFullScreen" value="true"></param>
    				<embed src="http://www.youtube.com/v/JaQtWg6bifw?fs=1&rel=0" type="application/x-shockwave-flash" width="560" height="315" allowfullscreen="true"></embed>
    				</object>

Viewing 3 replies - 1 through 3 (of 3 total)
  • Use regex to detect the tags, then use that.

    $source = <Full Content>;
    preg_match("'.*?(<object .*?>.*?</object>).*?'si", $source, $match);
    if($match) echo $match[1];

    Worked like a charm! Thankyou 🙂

    For those who just got here, replace
    <Full Content>;
    with
    get_the_content();

    Good to hear.

    Can you mark this as resolved? Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Truncate "the_content" to an element.’ is closed to new replies.