Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

content (not excerpt) read more WordPress



It's some time ago, and therefore I hope it would be OK to ask (:

Currently, I'm using the WordPress <!-- more --> tag to manually create excerpts of my content.

Now I've seen some snippets to change the way it jumps (to the beginning of the post in example) but almost nothing to remove the bloat that it's leaving behind.

Namely <br /><span id="more-19"></span><br />.

I can get rid of this myself: <span id="more-19"></span><br />, but somehow not the first br tag.

Preferably I'm looking for a code snippet that removes the <br /><span id="more-19"></span><br /> bit completely. ('19' being the WordPress post-ID)

AND replacing it by </p><p> (like it should).

Also, if you could include the code snippet in YOUR code to jump to the beginning of the post, you would most likely rate as 'awesome' in my most appreciated people list.

Answers (3)


Jurre Hanema answers:

Altough I don't really see the point of removing this "bloat" as you call it, this piece of code might help:

add_filter('the_content', 'wpq_the_content');

function wpq_the_content($content)
$content = preg_replace("/<br \/>\n*<span id=\"more-(\d+)\"><\/span><br \/>/", '</p><p id="more-$1">', $content);

return $content;

Note that this only applies to <!--more--> tags added using the HTML-editor and not to more-tags added using the WYSIWYG-editor (in which case the code becomes something like <p><span id="more-42"></span></p>).

cor comments:

Thanks Jurre,

Your snippet does exactly as asked.

Also thank you for fully reading the question in the first place.
Your solution is the only that removes the double br bit, which was basically the main question.

I didn't realize there would be a difference between the output of the wysiwyg and html editor, but as I normally avoid, disable or discourage people using the wysiwyg at all (unless there's a proper editor style available) that would be OK.

Just voted, and wederom bedankt,


cor comments:

*should be the wysiwyg <em>editor</em> at all...


rizaljohn answers:

How about using jquery:

cor comments:

Hi rizaljohn,

I have to admit, I'm not a jQuery expert. But, I usually try to avoid replacements using JS if possible.
This if only because of the people having JS disabled.

In this case I would prefer a php-ish solution.

rizaljohn comments:

You can try this code:
the_content('<p id="'. get_the_ID() .'">Read more...</p>');

rizaljohn comments:

To meet what you need:
the_content('<p id="more-'. get_the_ID() .'">Read more...</p>');
I just added 'more' to the p id.

Hope that helps.

cor comments:

Not exactly. As you perhaps have used the WordPress <!-- more --> function, you would know what bloat it outputs (single.php).

I'm not trying to replace <span id="more... by a <p id="more..., but trying to remove the <br /><span id="more-19"></span><br /> all together.

rizaljohn comments:

Okay. I got it.
So you may try code and put this in your functions.php:

// Puts link in excerpts more tag
function new_excerpt_more($more) {
return '</p><p>';
add_filter('the_content_more_link', 'new_excerpt_more');


Ivaylo Draganov answers:


this simple filter will get you rid of the extra bloat:

// remove <!-- more --> bloat
add_filter( 'the_content', 'remove_more_bloat' );

function remove_more_bloat( $content ) {

global $post;

if ( is_singular() )
$content = str_replace( '<span id="more-' . $post->ID . '"></span>', '', $content ); // replace the <span> with an empty string

return $content;



cor comments:

Hi Ivaylo,

I've tried this snippet before posting the question. It removes the span, but leaves a <br /><br /> as mentioned in the original question.