2015-02-23 58 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));