Forums

Jquery is not working (14 posts)

  1. plutarco
    Member
    Posted 4 months ago #

    Hi,

    I'm trying to manually load a jquery script in my theme, but I'm surely doing something wrong as is not working.
    First off I'm loading jquery in the header.php like this:
    <?php wp_enqueue_script("jquery"); ?>

    Then I'm loading the script:

    <script type="text/javascript"
       src="<?php bloginfo("template_url"); ?>/wp-content/themes/sandbox/js/fadeLinks.js"></script>

    And lastly I'm adding the css code directly to the style.css:

    a{
    	color:#f30;
    	font-weight:bold;
    	text-decoration:none;
    	}
    a span.two{
    	color:#069;
    	cursor:pointer;
    	}

    I guess I'm doing possibly everything in the wrong way.

  2. Pankaj Pandey
    Member
    Posted 4 months ago #

    <script type="text/javascript"
       src="<?php bloginfo('stylesheet_directory'); ?>/js/fadeLinks.js"></script>

    please note your "template_url" have double quote and i use single quote.

    also bloginfo("template_url") will return http://example/home/wp/wp-content/themes/parent-theme

    http://codex.wordpress.org/Function_Reference/bloginfo

  3. plutarco
    Member
    Posted 4 months ago #

    Thanks Pankaj,

    I've changed the above code like this:
    <?php wp_enqueue_script('jquery'); ?>

    and this:

    <script type="text/javascript"
       src="<?php bloginfo('wpurl'); ?>/wp-content/themes/sandbox/js/fadeLinks.js"></script>

    Since the bloginfo wpurl is = http://example/home/wp
    I assume that now the url should be interpreted like:
    http://example/home/wp/wp-content/themes/sandbox/js/fadeLinks.js

    but still it doesn't work.

  4. Pankaj Pandey
    Member
    Posted 4 months ago #

    is this site live. then give me the link. thanks

  5. plutarco
    Member
    Posted 4 months ago #

    Sure:
    http://blog.phoenixart.com/

    thank you very much Pankaj.

  6. Pankaj Pandey
    Member
    Posted 4 months ago #

    i cant see any reference to fadeLinks.js where you added that code?

  7. plutarco
    Member
    Posted 4 months ago #

    Right on the header.php, once loaded looks like this:

    <script type="text/javascript"
       src="http://blog.phoenixart.com/wp-content/themes/sandbox/js/fadeLinks.js"></script>
  8. Pankaj Pandey
    Member
    Posted 4 months ago #

    use pastebin and share you header.php code

  9. plutarco
    Member
    Posted 4 months ago #

  10. plutarco
    Member
    Posted 4 months ago #

    Any luck Pankaj?
    I did other tests but so far nothing is working.

  11. Pankaj Pandey
    Member
    Posted 4 months ago #

    Remove line 10 <?php wp_head() // For plugins ?> and see if work?

    If this work then some of your plugin is replacing the code of head.

    try to add this script in footer and see if this work.

    Thanks

  12. Webfaden
    Member
    Posted 4 months ago #

    I wouldn't recommend to delete <?php wp_head() ?>. Some plugins use it to get code into your header, so some things might not work. You should move it right before the </head> tag though! It's also important to have the <?php wp_footer(); ?> right before the </body> tag.

    Maybe it helps to just move the we_head, because it caused myself some trouble when I had it in the wrong position and not right before the head closing tag.

    Hope it helps!

  13. Pankaj Pandey
    Member
    Posted 4 months ago #

    I suggest to delete line and test if that work means that line is modified with some plugin. Bring that code back and load your script on footer.php it will solve problem easily.

  14. plutarco
    Member
    Posted 4 months ago #

    Thanks again Pankaj, thank you Webfaden for your tip,

    it seems there's no way to have the script working. At this point I give it up. Probably there could be some issue with the theme itself, not sure exactly what's going on. Jquery doesn't seem to be the issue as the plugins I load from WP control panel work fine.

    Pankaj, I've tried both removing that line and moving the script on the footer, nothing seems to work. I think I'll live without the fade script :)

Reply

You must log in to post.

About this Topic

Tags