SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Design and Promotion Crimson77's Avatar
    Join Date
    Aug 2006
    Location
    Australia
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adjusting WordPress script?

    Hi Guys,

    I'm trying to adjust the existing wordpress coding to allow for multiple CSS stylesheets.

    Attached is the header code which I'm pretty sure is what I need to change.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    
    <head profile="http://gmpg.org/xfn/11">
    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    
    <title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> &raquo; Blog Archive <?php } ?> <?php wp_title(); ?></title>
    
    <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats -->
    
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    
    <style type="text/css" media="screen">
    
    <?php
    // Checks to see whether it needs a sidebar or not
    if ( !$withcomments && !is_single() ) {
    ?>
    	#page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbg-<?php bloginfo('text_direction'); ?>.jpg") repeat-y top; border: none; }
    <?php } else { // No sidebar ?>
    	#page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgwide.jpg") repeat-y top; border: none; }
    <?php } ?>
    
    </style>
    
    <?php wp_head(); ?>
    </head>
    <body>
    <div id="page">
    
    
    <div id="header">
    
    	<div id="headerimg">
    		<h1><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h1>
    		<div class="description"><?php bloginfo('description'); ?></div>
    	</div>
    </div>
    <hr />
    As well as removing the internal stylesheet info in this script the code I need to change (I believe) is:
    Code:
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    I found this scripting for changing a header image, but I think it shouod be able to be adjusted to change the style sheets too.

    Code:
    <?php if(is_page()) : ?>
    <img src="/images/header-page.jpg" />
    <?php elseif(is_page('this-page') : ?>
    <img src="/images/this-page.jpg" />
    <?php elseif(is_page('that-page') : ?>
    <img src="/images/header-that-page.jpg" />
    <?php else : ?>
    <img src="/images/header.jpg" />
    <?php endif; ?>
    I was thinking of changing it to the following but it doesn't seem to work, probably because I don't know what to put in the 'this-page' etc areas. I'm be creating pages such as biography and aboutus but even though these are the titles that come up in the navigation I'm getting page like ?page_id=2 in the url area. Anyway what I tried was:
    Code:
    <?php if(is_page()) : ?>
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    <?php elseif(is_page('biography') : ?>
    <link rel="stylesheet" href="biography.css" type="text/css" media="screen" />
    <?php elseif(is_page('aboutus') : ?>
    <link rel="stylesheet" href="aboutus.css" type="text/css" media="screen" />
    <?php else : ?>
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    <?php endif; ?>
    I've also tried:
    Code:
    <?php if(is_page()) : ?>
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    <?php elseif(is_page('?page_id=2') : ?>
    <link rel="stylesheet" href="biography.css" type="text/css" media="screen" />
    <?php elseif(is_page('?page_id=3') : ?>
    <link rel="stylesheet" href="aboutus.css" type="text/css" media="screen" />
    <?php else : ?>
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    <?php endif; ?>
    If anyone here is familiar with wordpress I'd really be interested in the help. I think this would be a great technique to add more functionality to the CMS if we can work it out. Thanks.

  2. #2
    Is Still Alive silver trophybronze trophy RetroNetro's Avatar
    Join Date
    Jul 2003
    Location
    Texas
    Posts
    6,883
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hello

    If you want to add more style sheets you just need to add more of these for each stylesheet you wish to link to:
    Code HTML4Strict:
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    This path to the current themes stylesheet can be changed to:
    Code HTML4Strict:
    <?php bloginfo('template_directory'); ?>/mystyle.css
    More Info...

    Code PHP:
    <?php if(is_page()) : ?>
    <link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/mystyle.css" type="text/css" media="screen" />
    <?php elseif(is_page('page ID or TITLE') : ?>
    <!-- more stuff here -->
    <?php endif; ?>
    You can also have is_home(), is_archive(), is_date(), is_single() amongst others More info...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •