Я бы загрузил через ajax содержимое страницы, которая находится внутри шорткода одной из моих форм, созданных с помощью подключаемого модуля CF7. Когда контент отображается, шорткод не обрабатывается и печатается как текст. Есть ли способ принудительно выполнить шорткод в вызове ajax? Спасибо, М.
Это сценарий 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();
}