【发布时间】:2016-09-19 07:54:34
【问题描述】:
我正在使用简码来获取页面内容。短代码在 wp 编辑器中添加时运行良好,但它似乎不起作用或更好我说它在通过 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"] 在文本编辑器中添加时可以正常工作,但不能在 Ajax 中使用。任何帮助将不胜感激。
【问题讨论】:
-
在 ajax 中运行良好。你能把演示网址发给我吗?
-
谢谢穆克什。请查看这两个 URL ayanize.com/dev1(单击快速查看按钮)和此 URL ayanize.com/dev1/product/demo-product。拿着耳朵的人的图像是从页面 ID 中获取的内容,当单击“快速查看”按钮时,该 ID 不显示。
标签: jquery ajax wordpress shortcode