I'm using a modal to display some content via an admin-ajax request.

Now I have problem outputting the content of a sidebar (text widgets, used for adding advertisement scripts). When I directly use dynamic_sidebar('ads'), it outputs the content randomly all over the modal.

What I was able to do was to use output buffering.

    $ads = ob_get_contents();

And then use $ads later.

Isn't there a better way to do this?

PS : The modal script does not support the REST-API.

  • I have similar issue. I want to display some advertisement dynamically on ajax page load but seems like dynamic_sidebar is not supported with ajax call. Some pointers would be nice. Sep 19, 2020 at 20:56


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.