Ignore a more tag when using get_the_content()

This is such a simple question it seems yet I can’t find a definite answer on it.

So how do you make get_the_content() obtain all the content of a post even if it has <!--more--> inside of the text which normally makes the function return after it has been used ?

1 Answer
1

I would just get the raw content from $post->post_content, strip the <!--more--> and then do whatever you need with the result. Just remember, $post->post_content and get_the_content() both return unfiltered text, if you need filtered content, simply apply the the_content filter to the result from those two results

EXAMPLE inside the LOOP

global $post;
$unfiltered_content = str_replace( '<!--more-->', '', $post->post_content );
// If you need filtered content returned
$filtered_content = apply_filters( 'the_content', $unfiltered_content );
// Output filtered content
echo $filtered_content;

Leave a Comment