【发布时间】:2013-05-11 17:50:37
【问题描述】:
我将通过 ajax 加载页面内容,这些内容包含在我通过 CF7 插件生成的表单之一的简码内。 呈现内容时,不处理短代码并以文本形式打印。 无论如何在ajax调用中强制执行短代码? 谢谢, M.
这是js脚本:
function getcontent(postid){
// here is where the request will happen
jQuery.ajax({
url: '/wp-admin/admin-ajax.php',//ajax controller request
data:{
'action':'dch',//action invoked
'fn':'ghcontent',//function required
'postid':postid//if of post required
},
cache: false,
async:true,
timeout: 3000,
success:function(data){
jQuery("#posthome").html(data);//print the html (content)
},
error: function(errorThrown){
console.log(errorThrown);
}
});
}
这是我的 php 代码:
add_action('wp_ajax_nopriv_dch', 'ghcontent');
add_action('wp_ajax_dch', 'ghcontent');
function ghcontent(){
$args = array('page_id' => $_REQUEST['postid']);
query_posts($args);
if(have_posts()) :
while (have_posts()) : the_post();
the_content();
endwhile;
endif;
die();
}
【问题讨论】:
标签: php jquery wordpress contact-form-7