我有一個 wordpress 站點和用于使用可視化編輯器創建頁面的Divi插件。我正在開發一個需要獲取某些頁面內容的插件。我知道使用 Divi 創建的頁面內容使用短代碼存儲在數據庫中。當我使用 wordpress 函數訪問頁面內容時,我得到的內容充滿了短代碼,但是每當您打開使用 Divi 構建的頁面時,我們都可以看到這些短代碼生成的渲染 HTML。我希望能夠在您訪問網站時呈現頁面。我不想刪除帖子的短代碼。是否有一個 wordpress 函數可以在您打開頁面時將內容呈現為呈現形式,或者是否有我可以使用的 Divi 函數?我已經嘗試使用這兩種方法$post = get_post(1);//Method 1echo do_shortcode( $post->post_content) ;//Method 2echo apply_filters('the_content', $post->post_content);但這些都沒有將 Divi 短代碼呈現為 html。
2 回答

慕尼黑8549860
TA貢獻1818條經驗 獲得超11個贊
完整代碼:
// Render content of Divi page "404 page"
$args = array(
'page_id' => 10302
);
$post_query = new WP_Query( $args );
if ( $post_query->have_posts() ) {
while ( $post_query->have_posts() ) {
$post_query->the_post();
$content = apply_filters( 'the_content', get_the_content() );
echo $content;
}
}
wp_reset_query();
- 2 回答
- 0 關注
- 184 瀏覽
添加回答
舉報
0/150
提交
取消