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

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

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?