Support » Plugin: amr shortcode any widget » load shortcode via ajax

  • Hello, i’m trying to load the content of a widget using shortcodes and ajax.
    My problem is that i need to collect all widgets in Widgets for shortcodes sidebar, but executing [do_widget id=x] using do_shortcode function and ajax not working, it return an empty string. However, placing this shortcode on a page work fine also executing [do_widget_area …] work fine via ajax.

    Please, can you tell me how to resolve this. Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author anmari


    If you are programming then you should not be using this plugin. It’s intended for non-programmers and is a “workaround”. It is simply trapping the output of the widgets and returning it.

    That said wrt ajax: I suspect the answer to whatever it is you are trying to do is to “do it differently”. See the detailed explanation on this, in particular the bold piece
    Rule: Never try to run shortcodes inside AJAX or Admin requests.

    Ask yourself why are you using ajax? and why via a shortcode, why can you not load the widgets normally? or use a sidebar in your theme if you need multiple widgets. Read this and

    Good luck

    For a custom needs, i should load content of some posts via ajax into a custom template page. i used apply_filters( ‘the_content’, $key->content ); and it was working perfect on my wordpress pages. But when i have update the version of WP to 4.9.8 it has stopped and ajax response is just an empty string for some shortcodes or a non completely loaded content for some others.

    after some search i add this snippet

    /* — Necessary since Visual Compoer V 4.9 — */ if ( class_exists( ‘WPBMap’ ) && method_exists( ‘WPBMap’, ‘addAllMappedShortcodes’ ) ) {


    do_action( ‘template_redirect’ );

    but the problem was not solved!

    Plugin Author anmari


    I’m sorry I cannot help your further, please see my earlier response.

    Well-well, anmari,

    do you use the_content WP filter for the standard output?
    If no, plugin doesn’t work with ajax. But a lot of themes have infinite scroll feature for the autoload next post.

    Plugin Author anmari


    Plugin does normal shortcode, so yes it will return output to the wp filter when wp applies it.

    ALL the plugin really does is trap the widget output (because widgets echo output directly, rather than ‘returning’ the text) and then returns that trapped output like normal shortcode return.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘load shortcode via ajax’ is closed to new replies.