Support » Plugin: Raw HTML » raw with strip_shortcodes

  • i am using strip_shortcodes function to display an excerpt but it does not remove the -raw- shortcode. it removes all shortcodes except raw. how can i make it remove raw as well? thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Janis Elsts


    Normally, if you retrieve the excerpt using the get_the_excerpt() function, the plugin itself will automatically remove [raw] blocks from the excerpt. Are you using a different approach to generate the excerpt?

    thanks for the quick reply. yes i am using a different way of generating the excerpt with a custom function

    /* Function -- Get excerpt by post id */
    	function get_excerpt_by_ID($post_id){
    	    $the_post = get_post($post_id); //Gets post ID
    	    $the_excerpt = $the_post->post_content; //Gets post_content to be used as a basis for the excerpt
    	    $excerpt_length = 35; //Sets excerpt length by word count
    	    $the_excerpt = strip_tags(strip_shortcodes($the_excerpt)); //Strips tags and images
    	    $words = explode(' ', $the_excerpt, $excerpt_length + 1);
    	    if(count($words) > $excerpt_length) :
    	        array_push($words, '…');
    	        $the_excerpt = implode(' ', $words);
    	    $the_excerpt = '<p>' . $the_excerpt . '</p>';
    	    return $the_excerpt;
    Plugin Author Janis Elsts


    If possible, try running the result through the get_the_excerpt filter. Something like this:
    $the_excerpt = apply_filters('get_the_excerpt', $the_excerpt, $the_post)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘raw with strip_shortcodes’ is closed to new replies.