Direct call to short code or function
-
Great plugin.
Having one issue with a current attempt usage though.I’m attempting to call the shortcode via the do_shortcode command and for the life of me can’t get it to work.
I can get it to work if I echo out the results but as I’m attempting to swap it on a filter I need to return the results and echo will just output to the top of the page. This is my attempt:
if(isset($attr['gallery_type']) && $attr['gallery_type'] == "justified") { $ids = $attr['ids']; /** Start an output buffer to capture the echo */ ob_start(); echo do_shortcode('[justified_image_grid ids='.$ids.']'); $output = ob_get_contents(); ob_get_clean(); } return $output;
If I remove the ob_get_clean I can return the results but again at the top of the page.
My attempt above outputs nothing.Is it possible to call the function I need directly and pass in the ids to avoid the do_shortcode and store the gallery in a variable to be returned?
If so what would that look like?Thanks for any assistance!
- The topic ‘Direct call to short code or function’ is closed to new replies.