在WordPress中输出格式化文本(ul和li改为p标签问题)
Output formatted Text in WordPress (ul and li changed to p tag issue)
我使用的是现成的主题,其中职位描述未显示格式化文本。
下面几行WordPress单post代码:
$job_about_me = html_entity_decode(get_post_meta($post->ID, htmlentities(stripslashes('job-about-me')),true));
$content = $job_about_me;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo wpautop($content);
所以,这段代码的输出如下所示:
.full {
margin-left: 0;
width: 100%;
float: left;
position: relative;
margin-bottom: 30px;
}
<div class="full" style="margin-bottom: 0;">
<p>Shirish</p>
<p>Gururaj</p>
<p>Jay</p>
</div>
我希望代码的输出在 ul 和 li 而不是 p 标签中。
简而言之,格式化 HTML 页面应该可见。
我尝试了很多,但需要你的帮助。
为什么不试试 str_replace()
?
echo str_replace(
array( '<div', '</div>' '<p', '</p>' ),
array( '<ul', '</ul>', '<li', '</li>' ),
wpautop( $content )
);
我使用的是现成的主题,其中职位描述未显示格式化文本。
下面几行WordPress单post代码:
$job_about_me = html_entity_decode(get_post_meta($post->ID, htmlentities(stripslashes('job-about-me')),true));
$content = $job_about_me;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo wpautop($content);
所以,这段代码的输出如下所示:
.full {
margin-left: 0;
width: 100%;
float: left;
position: relative;
margin-bottom: 30px;
}
<div class="full" style="margin-bottom: 0;">
<p>Shirish</p>
<p>Gururaj</p>
<p>Jay</p>
</div>
我希望代码的输出在 ul 和 li 而不是 p 标签中。
简而言之,格式化 HTML 页面应该可见。
我尝试了很多,但需要你的帮助。
为什么不试试 str_replace()
?
echo str_replace(
array( '<div', '</div>' '<p', '</p>' ),
array( '<ul', '</ul>', '<li', '</li>' ),
wpautop( $content )
);