1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Wordpress - How To Add Javascript?

Discussion in 'Blogging' started by ams007, Nov 27, 2008.

  1. ams007

    ams007 Junior Member

    Joined:
    Apr 18, 2008
    Messages:
    198
    Likes Received:
    41
    Location:
    North America
    Happy Thanksgiving!

    Now, back to business. I am trying to add:

    <!--Start Etology Code-->
    <script charset="utf-8" type="text/javascript" src="http://pages.etology.com/js2/99999.php" language="javascript"></script>
    <!--End Etology Code-->

    to wordpress sidebar (preferably) between archive and blogroll. If sidebar is not possible, I would settle for placing it in a post. How do I do it?

    Please help.


    Sidebar code below:


    <div class="navigation">

    <div id="sidebar">

    <?php if ( !function_exists('dynamic_sidebar')
    || !dynamic_sidebar() ) : ?>

    <h2>Categories</h2>

    <ul>
    <?php wp_list_cats('sort_column=name&hierarchical=0'); ?>
    </ul>
    <h2>Archives</h2>
    <ul>
    <?php wp_get_archives('type=monthly'); ?>
    </ul>

    <h2><?php _e('Blogroll'); ?></h2>

    <ul>
    <?php get_links(-1, '<li>', '</li>', '', FALSE, 'name', FALSE, FALSE, -1, FALSE); ?>
    </ul>

    <h2><?php _e('Meta'); ?></h2>
    <ul>
    <li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php _e('Syndicate this site using RSS'); ?>"><?php _e('<abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>

    <li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php _e('The latest comments to all posts in RSS'); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
    <li><a href="http://validator.w3.org/check/referer" title="<?php _e('This page validates as XHTML 1.0 Transitional'); ?>"><?php _e('Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr>'); ?></a></li>

    <li><a href="http://gmpg.org/xfn/"><abbr title="XHTML Friends Network">XFN</abbr></a></li>
    <?php wp_meta(); ?>

    </ul>
    <?php endif; ?>
    </div>

    </div>
     
    Last edited: Nov 27, 2008
  2. ams007

    ams007 Junior Member

    Joined:
    Apr 18, 2008
    Messages:
    198
    Likes Received:
    41
    Location:
    North America
    I tried just copying/pasting the code there, but it did not work.
     
  3. jazz99

    jazz99 Regular Member

    Joined:
    Mar 24, 2008
    Messages:
    220
    Likes Received:
    50
    Location:
    USA
    You can just add it to a sidebar widget and it will work fine. I do it all the time
     
  4. ams007

    ams007 Junior Member

    Joined:
    Apr 18, 2008
    Messages:
    198
    Likes Received:
    41
    Location:
    North America
    Banarm, it inserts a block of ads, kinda like adsense.

    Jazz99, can you recommend a widget? I am new to wordpress ;)
     
    Last edited: Nov 27, 2008
  5. ams007

    ams007 Junior Member

    Joined:
    Apr 18, 2008
    Messages:
    198
    Likes Received:
    41
    Location:
    North America
    This worked:

    Create a new, blank text widget in Presentation > Widgets. Drag it to your sidebar. Open the widget, past the javascript source code.

    Thanks for all your responses!
     
  6. gucci

    gucci BANNED BANNED

    Joined:
    Sep 21, 2008
    Messages:
    36
    Likes Received:
    62
    You can check this site, might help you I guess.

    Code:
    http://www.wordpresstraining.com
     
  7. dynamicvb

    dynamicvb Regular Member

    Joined:
    Sep 2, 2007
    Messages:
    389
    Likes Received:
    185

    Yep, this is the easiest way I know and I use it all the time on a lot of blogs.
     
  8. trigger_my_passion

    trigger_my_passion Junior Member

    Joined:
    Oct 2, 2008
    Messages:
    108
    Likes Received:
    483
    Try this: If you want to just edit the code in sidebar.php, make sure you enclose the javascript code in unordered list like so:

    Code:
    <h2>Etology Ads</h2>
    <ul>
    <li>
    <!--Start Etology Code-->
    <script charset="utf-8" type="text/javascript" src="http://pages.etology.com/js2/99999.php" language="javascript"></script>
    <!--End Etology Code-->
    </li>
    </ul>