• For a kind of search function I need the posts text without html tags and without embeeded stuff.

    Currently I use

    $text = get_the_content('');
    	$text = apply_filters('the_content', $text);
    	$text = strip_shortcodes($text);
    	$text = str_replace(']]>', ']]>', $text);
    	$text = strip_tags($text);

    It works so far, but if a posts contains embedded vidoes, there is the url of the video included in $text. This is undesired.

    For example: get_the_content has

    This is my dem video:
    <video class=”wp-video-shortcode” id=”video-15-1″ width=”640″ height=”360″ preload=”metadata” controls=”controls”><source type=”video/mp4″ src=”pathtouploaded.mp4″ />pathtouploaded.mp4</video>
    Is it great?

    After apply_filters, strip_shortcodes, str_replace, strip_tags it is

    This is my dem video: pathtouploaded.mp4 Is it great?

    But what I want is to get only

    This is my dem video: Is it great?

    Thanks for your help.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You could use preg_replace() to strip out the entire embed block before you call strip_tags(). Like this:
    $text = preg_replace(‘/<video.*\/video>/i’, ”, $text );

    You’d need a similar line for every different embed tag that is causing issues.

Viewing 1 replies (of 1 total)
  • The topic ‘get_the_content without url from embedded video’ is closed to new replies.