简体   繁体   English

WordPress主题不允许我的内容中包含HTML

[英]WordPress theme is not allowing HTML in my content

I have a blog running on MemberPress and I am trying to add a 我有一个在MemberPress上运行的博客,我正在尝试添加一个
in the content of my blog posts to add a new paragraph. 在我的博客文章的内容中添加一个新段落。

When I add the < br / > it does not work, see the image. 当我添加< br / >无效时,请参见图片。

My theme does not seem to be rendering the HTML in the post. 我的主题似乎并没有呈现帖子中的HTML。 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? 我是否需要在PHP代码中添加一些内容,以使帖子显示输入的HTML?

Here is the PHP for the blog content: 这是博客内容的PHP:

<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行的文章:

帖子显示3行

The wp_trim_words function you're using strips all HTML tags out. 您正在使用的wp_trim_words函数将所有HTML标记剥离。

https://core.trac.wordpress.org/browser/tags/4.9.8/src/wp-includes/formatting.php#L3359 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.) (即使不是,您在使用esc_html函数之后也会破坏帖子中的HTML标记。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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