i would load via ajax the content of page that have inside the shortcode of one of my form generated via CF7 Plugin. When the content is rendered the shortcode is not processed and come print as text. Is there anyway to force execution of shortcode in an ajax call? Thank you, M.
This is the js script:
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);
}
});
}
And this is my php code:
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();
}