dsqnonh2763 2018-11-23 01:35
浏览 151
已采纳

WordPress主题不允许在我的内容中使用HTML

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 post showing 3 lines on one

  • 写回答

1条回答 默认 最新

  • douqu8828 2018-11-23 02:13
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况