Tagged: ,

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2914

    Hello – I want to include the jQuery maphilight plugin for a page in which we have created a navigation wheel. When I include the scripts the plugin works but conflicts with the accordion slider on the homepage. The plugin can be found here: http://plugins.jquery.com/project/maphilight . I uploaded the jQuery plugin to the js folder in newscast and called it in the header like this:

    <script type=’text/javascript’ src='<?php echo get_bloginfo(‘template_url’); ?>/js/jquery.maphilight.js’></script>

    <script>$(function() {

    $(‘.map’).maphilight();

    });</script>

    That didn’t work until I also included the function in the custom.js file like this:

    jQuery(‘.map’).maphilight();

    });

    Only then did it work – but also conflicted with the accordion slider.

    How can I include this plugin on a page without conflicting with the slider. Any help would be appreciated.

    Thanks!!

    #39781

    Hey,

    try to use “jQuery” instead of “$” like:

    <script type='text/javascript' src='<?php echo get_bloginfo('template_url'); ?>/js/jquery.maphilight.js'></script>
    <script>jQuery(function() {
    jQuery('.map').maphilight();
    });</script>

    #39782

    I tried that. Didn’t work…and if it does – messes up the accordion. Any way to call the plugin on a specific page only? Should I make a template for it?

    #39783

    You can include javascripts on specific pages by using condional tags: http://codex.wordpress.org/Conditional_Tags

    Open up header.php and replace following code:

    <!-- scripts -->

    with:

    <?php
    if (is_page(array(42,35,21)) || is_single(array(17, 19, 1, 11)) ) { ?>

    <script type='text/javascript' src='<?php echo get_bloginfo('template_url'); ?>/js/jquery.maphilight.js'></script>
    <script>jQuery(function() {
    jQuery('.map').maphilight();
    });</script>

    <?php } ?>

    <!-- scripts -->

    Replace the page ids with your page ids and the posts ids with your post ids (so you choose the pages + posts where you want to include the js file).

    #39784

    Thanks! I got the plugin to work and not mess up the accordion. But for some reason it won’t work unless the PNG image is transparent. It works in an HTML doc, but not with this wordpress theme. I had to make the PNG transparent.

    See it here:

    http://thecsr.org/programs-resources-ministries-main

    #39785

    Please talk to the authors of the plugin. That’s more a plugin related question than a theme support question.

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Including other jQuery plugins’ is closed to new replies.