WordPress.org

Support

Support » How-To and Troubleshooting » Header Tag – Add CSS link

Header Tag – Add CSS link

  • nono5551212
    Member

    @nono5551212

    Where do I go if i wanted to add my own css to my site….
    I wanna add a few javascripts to my header tag… Where can I do this?

    Thanks in advance

    <head>
    </head>
Viewing 5 replies - 1 through 5 (of 5 total)
  • Dagon Design
    Member

    @dagon-design

    You can edit the header.php in the directory of your active theme. It contains the header tags.

    /wp-content/themes/(yourtheme)/header.php

    nono5551212
    Member

    @nono5551212

    Thanks for the reply.

    Open header.php
    In between your <head> </head> tags add your code

    <script type="text/javascript" src="path/mootools-release-1.11.js"></script>
    <script type="text/javascript" src="path/rokbox.js"></script>
    <link href="path/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="path/rokbox-config.js"></script>

    I was trying to get Rokbox to work. It’s like lightbox and thickbox but a little better… see a demo here http://www.rocketwerx.com/products/rokbox/demo … maybe someone else will have better luck than me.

    michaeltyson
    Member

    @michaeltyson

    Just a note in case other people have this idea – a far, far better idea is to throw that stuff into a plugin file. It really isn’t much harder and it allows you to not lose all of your custom content whenever you upgrade/change your theme.

    Create a php file in wp-content/plugins, say ‘my_header_content.php’

    Put this in it:

    <?php
    /*
    Plugin Name: My header content
    Plugin URI:
    Description: Add some custom header content
    Author: Me
    Version: 1.0
    Author URI:
    */
    
    function my_header_content() {
      ?>
      <!-- Put your custom header content here, between the ?> and <?php -->
      <?php
    }
    
    add_action( 'wp_head', 'my_header_content' ); // 'my_header_content' here is the name of the function above
    
    ?>

    Then find the new plugin called ‘My header content’ in the plugins list and activate it. Voila, the ‘right way’.

    Lemonhead
    Member

    @lemonhead

    I’m somewhat new to amending code, but why can’t you create a php file and input the addcss function ? Why do you need to do this as a plugin ?

    Hi I’m writing a plugin to add some options to the admin post area.

    I would like to add my own css style sheet or any script file I may have to the admin header tag without having to manually add anything to the wordpress files.

    Is there a function that will do this?

    I assumed the function above was for the blog site itself not the admin pages.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Header Tag – Add CSS link’ is closed to new replies.