• Resolved Devin Price

    (@downstairsdev)


    I have a site where I’d like to use the more tag, but I don’t want the images I have set at the top of the post to show up.

    For the moment I am hacked something together to strip all the html tags:

    /* Custom Excerpt Function */
    
    function wpt_strip_content_tags($content) {
    	$content = $post->post_content;
    	$content = strip_shortcodes($content);
    	$content = str_replace(']]>', ']]>', $content);
    	$content = strip_tags($content);
    	return $content;
    }

    And here’s how it’s displayed:

    $excerpt_content = get_the_content('');
    								echo '<p>' . strip_tags($excerpt_content) . '</p>';

    But I’m wondering if there’s a simpler way to do this.

Viewing 1 replies (of 1 total)
  • Thread Starter Devin Price

    (@downstairsdev)

    Okay, think I got this resolved to be more what I wanted:

    function wpt_strip_content_tags($content) {
    	$content = strip_shortcodes($content);
    	$content = str_replace(']]>', ']]>', $content);
    	$content = preg_replace('/<img[^>]+./','',$content);
    	return $content;
    }

    Display:

    $excerpt_content = get_the_content('');
    echo wpt_strip_content_tags($excerpt_content);
Viewing 1 replies (of 1 total)
  • The topic ‘Displaying the_content until the more tag and stripping html’ is closed to new replies.