Support » Themes and Templates » Help with javascript and wordpress

  • I have made a css layout with a css menu using the code from here :

    However when I started to convert the layout into a wordpress theme the javascript part of the menu does not work.

    Please may someone show me the code that will make the menu function fully in a wordpress theme?

    Thanks in advance for any help!


Viewing 4 replies - 1 through 4 (of 4 total)
  • Link to the site?

    Your javascript calls will probably need to go in header.php of your theme.

    Im running it on localhost but here is the code im using:
    This is in the head tag:

    `<script language=”javascript” src=”scripts/mootools.js” type=”text/javascript”></script>
    <script language=”javascript” src=”scripts/menu.js” type=”text/javascript”></script>’

    And this is the menu I would like the javascript to work with:

    ‘<div id=”fancymenu”>

      <li class=”current” id=”menu_home”>Home
      <li id=”menu_archives”>Archives
      <li id=”menu_about”>About
      <li id=”menu_downloads”>Downloads
      <li id=”menu_contact”>Contact


    This worked when I made the css template – as soon as I converted it to a wordpress theme the javascript stopped working.

    Thanks for your help.

    Where are your javascript files placed? Are they in the same directory as your theme, or are they stored somewhere near the root of your site?

    If they are in the same directory of your theme, then add <?php bloginfo('template_directory'); ?> to the beginning of your src= path. Remember that even tho your header.php is physically located in your themes/ folder, when it is called and processed, it will be done at the root of your site, so you have to think where your files are relative to this.

    (BTW, the backtick is located usually left of the 1 on the keyboard. Took me forever to find that character… ;-))

    Thanks for the response, your advice worked. 🙂

    I’m really greatful!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Help with javascript and wordpress’ is closed to new replies.