2015-02-23 47 views
0

每当我尝试回复帖子的内容时,我会得到没有html标签的内容。像段落一样。用ID保留段落回复帖子

有没有一种方法来回显他们与段落等?

现在这是我的PHP代码:

 $post_id = 1231; 
     $queried_post = get_post($post_id); 
     echo $queried_post->post_content; 
+0

Can你提供任何你想要实现的例子吗? – 2015-02-23 11:07:53

+0

这是它在实际页面上的样子: http://i60.tinypic.com/14jnlt5.png 但是,当我尝试在另一页上显示该页面的内容时, : http://i62.tinypic.com/11hgvgg.png 我读过应用过滤器,但没有运气。我有麻烦用我自己的例子。 apply_filters('the_content',$ post-> post_content); – Philip 2015-02-23 11:18:09

回答

0

使用the_content();echo get_the_content();

由于此功能使用WP过滤器the_content,该过滤器使用 'wpautop' 过滤器。

哪些广告p标签

这里是扣

   <?php 
       $post_id = 1226; 
       $post_local = get_post($post_id); 
       if($post_local){ 
        setup_postdata($post_local); 
        echo wp_autop(get_the_content()); 
       } 
      ?> 
+0

当我像这样使用它时,没有任何反应。你能告诉我我做错了什么吗? :) 谢谢! $ post_id = 1226; 回声get_the_content($ POST_ID) – Philip 2015-02-23 11:23:06

+0

这对我的作品,但这种方法可能有点过时: $ my_postid = 12; //这是网页ID或交ID $ content_post = get_post($ my_postid); $ content = $ content_post-> post_content; $ content = apply_filters('the_content',$ content); $ content = str_replace(']]>',']] >',$ content); echo $ content; – Philip 2015-02-23 11:24:40

+0

当我使用捕捉它仍然剥离P标签:/ Hmzz – Philip 2015-02-23 11:31:10

0

你可以用这样的输出内容与html标签

echo str_replace("\r", "<br />", get_the_content('')); 
+0

感谢您的回答 – Philip 2015-02-23 11:24:55

+0

欢迎您..它工作吗? – Asif 2015-02-23 11:27:45

1

这个工作对我来说:

$post_id = 1226; 
echo apply_filters('the_content', get_post_field('post_content', $post_id));