Site logo

Archived topic

Shortcode Hook returning empty

1 reply · Started by THIAGO on April 11, 2023

Viewing posts 1–2 of 2

Hey,

I'm using a generatepress Custom Hook as a shortcode using this function:

function customFunc($atts, $content = null) {
      ob_start();
      do_action('customHook');
      return ob_get_clean();
}
add_shortcode('myShortcode', 'customFunc');

This shortcode works OK in my pages but it is returning empty when I try to save its value into a variable in Ad Inserter:

$code = do_shortcode('[myShortcode]');

That means $code is always empty even if the shortcode works ok in my posts. Why is this happening?

Hi there,

The code should work, but this is not related to the GP theme as you are using it in codes that from 3rd party, I would recommend contacting your ads provider for how to integrate the shortcode into their code.

This archived topic is closed to new replies.