第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

通過 ID 獲取 the_content 并在 WordPress 中保留 <p>-tag

通過 ID 獲取 the_content 并在 WordPress 中保留 <p>-tag

PHP
回首憶惘然 2021-06-12 14:17:23
我想通過 ID 獲取自定義帖子類型的內(nèi)容,并在短代碼中返回它。我找到了多種方法來做到這一點(diǎn)。但是他們<p>都從內(nèi)容中刪除了-tags。這是我嘗試過的:// Get the ID from a meta field$post_id        = $id;// Method 1$banner_content = get_post($post_id);$content = $banner_content->post_content;// Method 2$content = apply_filters('the_content', get_post_field('post_content', $post_id));// Method 3$content_post = get_post($post_id);$content = $content_post->post_content;$content = apply_filters('the_content', $content);$content = str_replace(']]>', ']]&gt;', $content);// Method 4$content = get_post_field('post_content', $post_id);// Output in a shortcodereturn '<div>'.$content.'</div>';有沒有辦法保留<p>-tag?
查看完整描述

1 回答

?
GCT1015

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超4個(gè)贊

對于我的示例,這有效:

return '<div>'.wpautop($content).'</div>';


查看完整回答
反對 回復(fù) 2021-06-13
  • 1 回答
  • 0 關(guān)注
  • 142 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號