[Support request] Insert hook via shortcode/into custom area on page

Home Forums Support Insert hook via shortcode/into custom area on page

  • This topic has 6 replies, 2 voices, and was last updated 1 year ago by David.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1000194
    Heather

    Hi,

    I was wondering if there was a way to insert a hook anywhere on a page. I am trying to nestle a hook with php in between two sections on a page, and I was wondering if I could do that by a short code? Or if I get the section I want the hook to exist in a class I can create a custom hook that goes in that class, or after the class of the above section – above_class_hook or something.

    I want to attach an image to help explain it better, is there a way to attach one without a url? I am building the website on a stage/dev server so I can’t link it or photos from it.

    #1000290
    David
    Staff
    Customer Support

    Hi there,

    can you explain what you’re tying to do and what the purpose of the Hook is?
    You can share any images here by providing a link to a share file location like GoogleDrive or using one of the screenshot sharing sites.

    #1000334
    Heather

    Hi David,

    So I am trying to insert a hook with php into a specific part of a page. As you can see from this attached image, I am trying to insert the “customer success” section as a hook in between those two other sections, as it will be pulling in a post from a specific category. I am just not sure how to be able to place it in there or if it is even possible.

    screenshot

    #1000337
    Heather

    sorry, original image wasn’t shareable

    screenshot

    #1000415
    David
    Staff
    Customer Support

    What is stopping you from just outputing that PHP with the Short Code? Not sure why PHP in Hook in Short Code is necessary. Let me know.

    #1001687
    Heather

    Sorry I’m not really sure what you mean.

    #1002114
    David
    Staff
    Customer Support

    Ok so there is this snippet:

    function your_shortcode($atts, $content = null) {
          ob_start();
          do_action('your_hook_name');
          return ob_get_clean();
    }
    add_shortcode('shortcode_name', 'your_shortcode');

    Which allows you to register an Action Hook inside a Shortcode.

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