![](/img/trans.png)
[英]wp_head(); isn't allowing all my HTML content to load in WordPress
[英]WordPress theme is not allowing HTML in my content
我有一個在MemberPress上運行的博客,我正在嘗試添加一個
在我的博客文章的內容中添加一個新段落。
當我添加< br / >
無效時,請參見圖片。
我的主題似乎並沒有呈現帖子中的HTML。 我嘗試了視覺編輯器和文本編輯器。
我是否需要在PHP代碼中添加一些內容,以使帖子顯示輸入的HTML?
這是博客內容的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>
這是一則顯示3行的文章:
您正在使用的wp_trim_words
函數將所有HTML標記剝離。
https://core.trac.wordpress.org/browser/tags/4.9.8/src/wp-includes/formatting.php#L3359
$text = wp_strip_all_tags( $text );
(即使不是,您在使用esc_html
函數之后也會破壞帖子中的HTML標記。)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.