简体   繁体   中英

WordPress theme is not allowing HTML in my content

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:

帖子显示3行

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.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM