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’ );

Execute shortcode only in another shortcode

To use a different callback for the nested headings switch the shortcode handler in the pricing_box callback and restore the main handler before you return the string. add_shortcode( ‘pricing_box’, ‘shortcode_pricing_box’ ); add_shortcode( ‘heading’, ‘shortcode_heading_main’ ); function shortcode_pricing_box( $atts, $content=”” ) { // switch shortcode handlers add_shortcode( ‘heading’, ‘shortcode_heading_pricing_box’ ); $out=”<div class=”pricing-box”>” . do_shortcode( $content ) … Read more

stray elements

Remove the filter from the the_content and run it after the shortcode are processed. Try: remove_filter( ‘the_content’, ‘wpautop’ ); add_filter( ‘the_content’, ‘wpautop’ , 12); Usually shortcodes are processed after wpautop is applied to the content. See http://core.trac.wordpress.org/browser/tags/3.1/wp-includes/shortcodes.php#L296

Why do_shortcode is not executing the shortcode in data-* html attributes?

do_shortcodes_in_html_tags() runs attributes through wp_kses_one_attr() which checks them against wp_kses_allowed_html( ‘post’ ) which by default only accepts standard non-data attributes, so you’d have to add your attribute: add_filter( ‘wp_kses_allowed_html’, function ( $allowedposttags, $context ) { if ( $context == ‘post’ ) { $allowedposttags[‘a’][‘data-abc’] = 1; } return $allowedposttags; }, 10, 2 );