Support » Fixing WordPress » Problem getting javascript matching columns to work

  • Resolved magicalwonders

    (@magicalwonders)


    Hello folks,

    I’ve made a wordpress theme by converting an xhtml design into php. Although my code is valid I’m having a problem getting the sidebar to display properly when used in wordpress.

    You can see the results at this url: http://www.kidspartybags.biz/blog/

    The sidebar should be red from top to bottom. This is normally achieved by using an external script, as can be seen working here: http://www.magicalwonders.com/testphp/
    I’m not sure where to upload the script to in WordPress.

    I’m totally new to WordPress so have tried to find out how to apply javascript by looking at the Docs. I found a reference that gave an example path of <script type=”text/javascript” src=”/scripts/emailpage.js”></script>

    The only problem being is that there is no directory called “scripts” on a wordpress installation!

    I did find some scripts in “wp-includes/js” folder – so tried uploading my matching columns script by ftp to that location, but that doesn’t work either!

    So the big question is, where do you include a javascript file on WordPress, and how do your reference it in the head area of the header file?

    Hope someone can advise.

    Many thanks,

    Myles

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi

    A commonly used place to locate scripts is in a folder within the active theme folder /wp-content/themes/{themename}/js/ for example

    This can be referred to as
    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/script.js"></script>

    The best rule in working with WordPress is to only put your content in subfolders of /wp-content/. wp-includes is for files that are part of the WP core. They are potentially subject to change and overwrite with each release of WordPress.

    Thread Starter magicalwonders

    (@magicalwonders)

    Hi Thanks for the help.

    Originally I had the script located within the theme directory itself, as in /wp-content/themes/themename It sounds like I just need to create another directory within my theme called JS and put it in there. And reference it correctly of course!

    Thanks for the tip about the wp-includes folder!

    I’ll give this a go.

    Many thanks,

    Myles

    Thread Starter magicalwonders

    (@magicalwonders)

    Hooray, got this working!

    Many thanks again for the help.

    Best wishes,

    Myles

    Can’t see where to mark this as resolved?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Problem getting javascript matching columns to work’ is closed to new replies.