Tagged: functions, header, woocommerce
-
AuthorPosts
-
December 16, 2020 at 11:03 pm #1267956
I am looking for a way to add a panel of text (on every page) – like the one saying ‘Christmas Gift Ideas’ here: https://dawesjewellery.co.uk
I have created this one using the Colour Section element which works for this page, but I want to add the same panel on every page. I was hoping there might perhaps be a function that I could use to insert [xxxx] below the header throughout.
The main problem is that WooCommerce doesn’t have a simple way to add details like this, so my thinking was if I add it to the header instead it would not interfere with Woo.
Any ideas?
December 18, 2020 at 8:16 am #1268352Hey ColinWalton,
Please try enabling debug mode in order to see builder shortcodes: https://kriesi.at/documentation/enfold/intro-to-advanced-layout-builder/#debug-mode
Then add this to your functions.php file:
function colin_add_christmas_banner(){ echo do_shortcode('[your shortcode]'); } add_action('ava_after_main_container', 'colin_add_christmas_banner');
And replace [your shortcode], with the shortcode of your Color Section element.
Best regards,
RikardDecember 18, 2020 at 12:10 pm #1268385Hi Rikard,
Thank you this sounds promising! The bit I am suck on is creating the shortcode of your Color Section element.
Do you mean copying the enfold code complete? (shown in the private content), or is there a way to make this into a much shorter shortcode?
Thanks
December 21, 2020 at 2:34 am #1268910Hi,
Sorry for the late reply, yes you would use the code you posted, but please note that the quotes the code Rikard posted need to be double quotes “ next to the [your shortcode] like this:function colin_add_christmas_banner(){ echo do_shortcode("[your shortcode]"); } add_action('ava_after_main_container', 'colin_add_christmas_banner');
this is because the single quotes in the shortcode will break the function if it also is using single quotes to contain the shortcode. Hope that makes sense.
Best regards,
MikeDecember 21, 2020 at 12:32 pm #1269000Hi Mike,
Thanks that works – for the home page. But on other pages things go all over the place. I suspect the CSS for these pages will need tweaking to make it appear identically on each of the pages.
Thanks for the help, much appreciated.
Colin
December 21, 2020 at 2:52 pm #1269033Hi,
Glad this helped, in your shortcode above I don’t see a custom ID or class for the whole color section, adding one could help you apply the style to it easier across your whole site.Best regards,
MikeDecember 21, 2020 at 2:55 pm #1269034That’s a good idea, thank you!
C
December 22, 2020 at 6:18 am #1269238Hi,
Did you need additional help with this topic or shall we close?
Best regards,
Jordan Shannon -
AuthorPosts
- You must be logged in to reply to this topic.