每當我嘗試回覆帖子的內容時,我會得到沒有html標籤的內容。像段落一樣。用ID保留段落回覆帖子
有沒有一種方法來回顯他們與段落等?
現在這是我的PHP代碼:
$post_id = 1231;
$queried_post = get_post($post_id);
echo $queried_post->post_content;
每當我嘗試回覆帖子的內容時,我會得到沒有html標籤的內容。像段落一樣。用ID保留段落回覆帖子
有沒有一種方法來回顯他們與段落等?
現在這是我的PHP代碼:
$post_id = 1231;
$queried_post = get_post($post_id);
echo $queried_post->post_content;
使用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());
}
?>
當我像這樣使用它時,沒有任何反應。你能告訴我我做錯了什麼嗎? :) 謝謝! $ post_id = 1226; 回聲get_the_content($ POST_ID) – Philip 2015-02-23 11:23:06
這對我的作品,但這種方法可能有點過時: $ 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
當我使用捕捉它仍然剝離P標籤:/ Hmzz – Philip 2015-02-23 11:31:10
這個工作對我來說:
$post_id = 1226;
echo apply_filters('the_content', get_post_field('post_content', $post_id));
Can你提供任何你想要實現的例子嗎? – 2015-02-23 11:07:53
這是它在實際頁面上的樣子: 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