Products
GG网络技术分享 2025-03-18 16:12 8
I have a blog running on MemberPress and I am trying to add a
in the content of my blog posts to add a new paragraph.
When I add the < br / >
it does not work, see the image.
My theme does not seem to be rendering the HTML in the post. I tried the visual editor and the text editor.
Do I need to add something to my PHP code to make my posts show the HTML I enter?
Here is the PHP for the blog content:
<div class=\"entry-content\"><div class=\"entry-meta ht-post-info\">
<?php total_posted_on(); ?>
</div><!-- .entry-meta -->
<header class=\"entry-header\">
<?php the_title( sprintf( \'<h2 class=\"entry-title\"><a href=\"%s\" rel=\"bookmark\">\', esc_url( get_permalink() ) ), \'</a></h2>\' ); ?>
</header><!-- .entry-header -->
<div class=\"entry-categories\">
<?php echo total_entry_category(); // WPCS: XSS OK. ?>
</div>
<!-- .entry-content -->
<div class=\"entry-summary\" style=\"margin-left: 13%; margin-top: 2%;\">
<?php
if(has_category(\'premium\', $wp_query->post->ID)){
echo do_shortcode(\"[mepr-active rule=\'282\' ifallowed=\'show\' unauth=\'message\' unauth_message=\'This content is for authorized members only.\']\". esc_html(wp_trim_words( get_the_content(), 490 )).\"[/mepr-active]\");
}else{
echo esc_html(wp_trim_words( get_the_content(), 490 ));
}
?>
</div>
</div>
This is the post that showing 3 lines on one:
The wp_trim_words
function you\'re using strips all HTML tags out.
https://core.trac.wordpress.org/browser/tags/4.9.8/src/wp-includes/formatting.php#L3359
$text = wp_strip_all_tags( $text );
(Even if it didn\'t, your use of the esc_html
function after it would also break your HTML tags in the post.)
Demand feedback