Horje
content (not excerpt) read more - Wordpress Solution
[Solved] - content (not excerpt) read more - Wordpress Solution
Try following codes
Hello, It's some time ago, and therefore I hope it would be OK to ask (: Currently, I'm using the WordPress 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.

Solution - 1

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 tags added using the HTML-editor and not to more-tags added using the WYSIWYG-editor (in which case the code becomes something like

).


Solution - 2

How about using jquery:

$("<span/>").replaceWith("<p></p>");


Solution - 3

Hi, 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;
	
}
Cheers

Date: 2022-10-21 05:10:29
Category: Wordpress
More for You