Site logo

Archived topic

Script In Navigation Link - Is This Possible?

3 replies · Started by RJ on July 9, 2019

Viewing posts 1–4 of 4

Hey there,

I want to add the following script as a 'Subscribe' link in my navigation. So when folks click the link, it opens the shopping cart modal. Here's the code:

<script src="https://cdn.podia.com/embeds.js" async="async"></script>
<a href="https://community.eatweeds.co.uk/plantopedia" data-podia-embed="button" data-text="SUBSCRIBE - £30">SUBSCRIBE - £30</a>

Is it possible to do this?

TIA, Robin

Hi there,

simplest way would be to:

1. Create a new Hook Element:
https://docs.generatepress.com/article/hooks-element-overview/

1.1 Add just the <script> line on of the code to the content
1.2 Select the WP_head hook
1.3 Set Display rules to entire site

2. In your Menu add a new Custom Link
2.1 Leave the URL empty - you may have to add a # first and then remove it after the item is added.
2.2 Add the <a href> line of the code as the label

Only issue i can see is that the button will be embedded using an iFrame so styling it from within GP will be an issue ( you can't overwrite iFrame content styles from a 3rd party server - has to be on the server delivering the iframe ). So unless you can style it from the podia interface the other option is to change this:

data-podia-embed="button"

to

data-podia-embed="link"

Which will generate an unstyled link that you can style yourself with CSS ( we could help with that)

The other alternative is to hook the button into the nav - let me know if you would sooner do that.

Super duper Mr. D. Many thanks! That worked a treat. Used the Link instead of button.

Have a wonderful day, and thanks again. You're a star!

You're very welcome - glad to be of help

This archived topic is closed to new replies.