Site logo

Archived topic

Need help to embed Block-Element via shortcode (NH-site)

5 replies · Started by Sascha on March 9, 2023

Viewing posts 1–6 of 6

Hello,

on this site , I have created a Block-Element as a custom-hook-name "trainer1", display on "Entire Site".

Then I added the following code to the child-themes function.php:

function mb_shortcode1($atts, $content = null) {
      ob_start();
      do_action('trainer1');
      return ob_get_clean();
}
add_shortcode('trainer1_code', 'mb_shortcode1');

Finally, on this page I have added the shortcode [trainer1_code] as the last content block, and expected the Block-Element to be displayed, but it does not work.

Can you please help me troubleshooting this? Just in case I have admin-auto-login credentials in private notes field below.

Thanks in advance and kind regards
Sascha

Hi Sascha,

That should work.

We can't view the element and the page in question since you're currently on their edit pages. Once you're done editing, let us know and we'll re-check.

Hi,

oops, I have just closed the tabs for page & element, please go ahead :)

Thanks
Sascha

I see. You haven't set a display rule location yet. You'll need to add one first. :)

Oh, it didn't save it properly when I clicked update for the first time, now working perfectly, so thanks :)

You're welcome, Sascha! :)

This archived topic is closed to new replies.