Site logo

[Support request] Shortcode Hook returning empty

Home Forums Support [Support request] Shortcode Hook returning empty

Home Forums Support Shortcode Hook returning empty

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2606336
    THIAGO

    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?

    #2606341
    Ying
    Staff
    Customer Support

    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.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.