Site logo

Archived topic

Insert hook via shortcode/into custom area on page

6 replies · Started by Heather on September 3, 2019

Viewing posts 1–7 of 7

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.

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.

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

sorry, original image wasn't shareable

screenshot

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.

Sorry I'm not really sure what you mean.

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.

This archived topic is closed to new replies.