Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #718121

    I’m trying to add class directly on the menu link, not the outer elements covering the link.

    But directly on it or else the wistia popup class won’t work.

    Here’s the setup:
    Home | Product Tour } Pricing

    When someone clicks product tour, a wistia video pops up. But class needs to be added directly on the link

    How can i accomplish this?

    • This topic was modified 7 years, 12 months ago by M|C.
    #718145

    Hey M|C,

    When adding class in the menu (via Appearance > Menus) it would be added to li tag, still try to add a unique class to it, for example popup-link-wrap then add this code at the bottom of functions.php:

    function add_custom_script(){
    ?>
    <script type="text/javascript">
    (function($){
    	function myfunction() {
    		$("top").find(".popup-link-wrap a").addClass("your-class-here");
    	}
    
    	myfunction();
    })(jQuery);
    </script>
    <?php 
    }
    add_action('wp_footer', 'add_custom_script');

    Just replace your-class-here with the name of the class you want to use.

    Best regards,
    Nikko

    • This reply was modified 7 years, 11 months ago by Nikko.
    #718627

    @Nikko Thank you! It breaks placing in the child theme. Is this the proper code for the child theme?

    • This reply was modified 7 years, 11 months ago by M|C.
    #718987

    Hello

    #719095

    Hi,

    Please send us a temporary admin login and login URL so that we can have a closer look. You can post the details in the Private Content section of your reply.

    Best regards,
    Rikard

    #719137
    #719534

    Hey guys, were you able to check?

    #720150
    #720403

    Hey!

    I have added the code I have given above but I noticed there is already a function of the same name, I modified the code in your functions.php (code below) however when I checked the page source it seems that the cache prevents the new code to show up. I tried disabling the cache but couldn’t get it to work, can you try to clear and disable cache (deactivate also), then delete the cache files via ftp or cpanel.

    function add_popup_script(){
    ?>
    <script type="text/javascript">
    (function($){
    	function myfunction() {
    		$(".popup-link-wrap a").addClass("your-class-here");
    	}
    
    	myfunction();
    })(jQuery);
    </script>
    <?php 
    }
    add_action('wp_footer', 'add_popup_script');

    Best regards,
    Nikko

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