SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Aug 2008
    Posts
    328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    code won't work in wp

    So, I've gotten this code to work just find on its own page but when I put it into wordpress the images won't show and thus there is no slide show.

    I've reviewed and reviewed but see no errors. Toss me a bone here.

    http://binghamdentalutah.com/2nd-home-test/

  2. #2
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    It looks like there are a couple of small things falling over, no biggie, should be easy to solve.

    Firstly, I see you have the following scripts in the <head> section

    Code:
    <script type="text/javascript" src="http://binghamdentalutah.com/wp-content/themes/Bingham%20Dental%20Utah/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="http://binghamdentalutah.com/wp-content/themes/Bingham%20Dental%20Utah/js/faq.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
    <script src="http://binghamdentalutah.com/wp-content/themes/Bingham%20Dental%20Utah/js/slides.min.jquery.js"></script>
    And near the bottom of the page (probably in your footer.php)

    Code:
    <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js?ver=3.4.2'></script>
    It seems the first jQuery script (1.7.2) isn't on the server, no matter, we'll get rid of it anyway

    What happens next is that your faq.js gets executed, but it of course doesn't run because jQuery isn't yet defined.

    Next up, jQuery is included again, which is fine, but if the first jQuery *would* have loaded then it would now be overwritten.

    Now the slides.min would run, but because there is another reference to jQuery in the footer, the $ variable gets overwritten again, which means the slides plugin gets deleted inadvertently.

    I would recommend that you place your faq and slides plugin script in the footer of the theme, remove the reference to jquery 1.7.2 from the header, and remove the reference to jQuery 1.4 from the footer.

    I am assuming that the jQuery 1.5.1 in the header is the one that Wordpress injects into the header, let me know if this is an issue for you and I can show you how to prevent this from happening or how to change the version.
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  3. #3
    SitePoint Addict
    Join Date
    Aug 2008
    Posts
    328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For some reason wp is injecting the jquery 1.7.2 which has been annoying me for awhile.

    The faq script is removed too and is being inserted still. I just removed it from the server too because I don't need it anymore.

    I just put the <script src="http://binghamdentalutah.com/wp-content/themes/Bingham%20Dental%20Utah/js/slides.min.jquery.js"></script> in the footer.

    Also, I have no idea where this **** is coming from in the footer because its not in my footer or any of my templates <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js?ver=3.4.2'></script>

    Well, shoot its working now so thx. However, I don't know where that last part of code is coming from. I have to fix the alignment of some things but its working.

  4. #4
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BrianBam View Post
    For some reason wp is injecting the jquery 1.7.2 which has been annoying me for awhile.
    It would be worth checking your theme functions.php file (Or the template theme's functions.php if you're using a template). Quite often theme authors will inject their own version of jQuery.

    For example in a recent theme I worked on, I added the following to my functions.php
    PHP Code:
    /**  
      * Add jQuery from the CDN rather than Wordpress' bundled version  
      */
    if (!is_admin()) {    

        
    wp_deregister_script('jquery');    

        
    wp_register_script('jquery''http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js'falsenull);    

        
    wp_enqueue_script('jquery');


    Just do a search for wp_register_script and/or wp_enqueue_script in your theme/template folder to see what turns up.

    I suspect a script with the handle 'jquery' might be enqueued as well as one with another handle (like jquery1.4 or something like that). Ideally the theme would be amended so it only includes the one version of jQuery
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •