WordPress.org

Ready to get started?Download WordPress

Forums

Header Tag - Add CSS link (6 posts)

  1. nono5551212
    Member
    Posted 5 years ago #

    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>
  2. Dagon Design
    Member
    Posted 5 years ago #

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

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

  3. nono5551212
    Member
    Posted 5 years ago #

    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.

  4. michaeltyson
    Member
    Posted 5 years ago #

    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'.

  5. Lemonhead
    Member
    Posted 5 years ago #

    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 ?

  6. pjon24
    Member
    Posted 5 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic