I am currently creating a wordpress page based on the X Theme which utilises Cornerstone as a page builder.
I am trying to dynamically load pages into the main page with AJAX. For this I created a script making a request to admin-ajax.php
which works flawlessly.
Now the tricky part: I added a PHP snippet with the plugin Code Snippets containing the following code:
function get_case() {
global $wpdb;
$postNo = intval( $_POST['case'] );
$post = get_post($postID);
$content = apply_filters('the_content', $post->post_content);
$html = do_shortcode($content)
echo $html;
wp_die();
}
add_action( 'wp_ajax_get_case', 'get_case' );
add_action( 'wp_ajax_nopriv_get_case', 'get_case' );
This code returns correct results if I am using the wordpress page builder, however it simply returns the shortcodes of the theme if the page was built in Cornerstone.
e.g.
[cs_element_section _id=”1″][cs_element_row _id=”2″]...
Am I doing this correctly? Shouldn't do_shortcodes() resolve those shortcodes? Is there any other way to dynamically load sub pages?
Any help is appreciated.