Load page with AJAX and resolve X theme shortcodes

I have a problem working on a wordpress page based on the X theme.

I am currently 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() {
  $postNo = intval( $_POST['case'] );
  $post = get_post($postNo);
  $content = apply_filters('the_content', $post->post_content);
  exit( $content );
}

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? Is there any other way to dynamically load sub pages?

Thanks in advance.

Hi there,

Thanks for writing in.

It’s because cornerstone v2 element generates a shortcode that is only applicable to the page where it’s created. I recommend building your page from classic elements if you plan to use it that way :slight_smile:

Thanks!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.