我正在使用簡碼獲取頁面內容。短代碼在wp編輯器中添加時運行良好,但它似乎不工作或更好,我說它通過ajax時不解析。如何在Ajax中通過簡碼獲取內容
我在網站上顯示通過Ajax顯示WooCommerce產品信息的彈出窗口。簡碼僅顯示原始碼,不會被解析。這是簡碼
function fetch_content_shortcode($atts, $content = null)
{
global $post;
extract(shortcode_atts(array(
'id' => null
), $atts));
ob_start();
$output = apply_filters('the_content', get_post_field('post_content', $id));
$output .= ob_get_contents();
ob_end_clean();
return $output;
}
add_shortcode('fetch-content', 'fetch_content_shortcode');
在文本編輯器,但不與阿賈克斯添加時[fetch-content id="1234"]
正常工作的簡碼。任何幫助將是欣賞。
它在阿賈克斯工作得很好。你可以請給我演示網址? –
謝謝穆克什。請查看這兩個網址https://ayanize.com/dev1/(點擊快速查看按鈕)和此網址https://ayanize.com/dev1/product/demo-product/。該男子持有耳朵的圖像是從頁面ID獲取的內容,該頁面ID在點擊快速查看按鈕時不會顯示。 – Ayanize