Shortcodes not resolved in AJAX call response

Since version 4.9 visual composer added shortcode lazy loading. To use VC shortcodes on AJAX content use this function before printing the content WPBMap::addAllMappedShortcodes();. So below code may help you,

function get_page_content(){

    $id = $_REQUEST['id'];

    $page_data = get_page($id);

    WPBMap::addAllMappedShortcodes();

    echo apply_filters('the_content', $page_data->post_content);
    wp_die();
}
add_action( 'wp_ajax_nopriv_get_page_content', 'get_page_content' );
add_action( 'wp_ajax_get_page_content', 'get_page_content' );

Leave a Comment

error code: 523