Tag Info

Hot answers tagged

2

I'm not sure I fully understand, but this isn't the recommended way to load js in WordPress. You normally would load scripts using a special WordPress function in your theme's functions.php file. It's wp_enqueue_script(). More here: http://codex.wordpress.org/Function_Reference/wp_enqueue_script By the way, WP also has its own function that essentially is ...


1

Solution #1 (not ideal, but it works): // Live Chat Utility Link add_filter( 'wp_nav_menu_items', 'live_chat_utility_link', 10, 2 ); function live_chat_utility_link ( $items, $args ) { if ( $args->theme_location == 'utility' ) { $items .= '<li><a href="javascript:void(0);" onclick="olark(\'api.box.expand\')" class="livechat">Live ...


1

Good that it works. If it's for a client or if you just want cleaner code, you can do it as @Tom J Nowell suggested. Add a custom menu item, link it to nowhere or anywhere. Find out the menu item ID (every item has one), and then target that ID with jQuery. $("#menu-item-num").on("click", function(e){ e.preventDefault(); // olark code here ...


1

You'll need to load jQuery and your custom script file into WordPress first. Do this using wp_enqueue_scripts. Put this in functions.php in your theme directory. Make sure the path to the script file (I called it main.js here) is correct for your environment. function mytheme_load_js() { // load in jquery wp_enqueue_script( 'jquery' ); // register ...


1

Your question is a bit broad. We actually have a one question per post policy. I'm going to try to answer though My first question is, shouldn't most themes that you download out there automatically include jQuery in your header anyway? Well, basically correct. So many features today in a theme needs jquery to run properly. I haven't came across a ...



Only top voted, non community-wiki answers of a minimum length are eligible