WordPress.org

Support

Support » How-To and Troubleshooting » Default Kubrick theme & $body_id

Default Kubrick theme & $body_id

  • I managed to grab the latest nightly and saw that Kubrick has become the default theme of WordPress, which is excellent, and I’ve started modifying it to suit my needs.

    I want to change the body id of specific pages, for example the body id for single.php is <body id=”archives”> and for index.php is <body id=”blog”> so that my navigation menu shows the correct colours on the different pages.

    I used to be able to define <?php $body_id = ‘blog’; ?> before the start of the call for the header.php and change my header.php to have the line <body id=”<?php echo $body_id; ?>”>
    Somehow, after switching to the default theme rather than using Ryan’s kubrick 1.3-rc2, the call for the header.php changed to <?php get_header(); ?> instead of <?php include(‘header.php’); ?> and the whole $body_id thing doesn’t work anymore.

    I hope you guys understand what I am trying to say here. Any help will be appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)
  • get_header only does the following:

    5 function get_header() {
    6 if ( file_exists( TEMPLATEPATH . '/header.php') )
    7 load_template( TEMPLATEPATH . '/header.php');
    8 else
    9 load_template( ABSPATH . 'wp-content/themes/default/header.php');
    10 }

    That is, it uses the header.php for the theme you are using, or it uses the header from the default theme (look above for the directory)

    So your way should still work if you edit the right header.php files.

    Yes, I edited the correct header.php.

    To make things sound simple, I am curious why <?php $body_id = blog; ?> on the first line of index.php has no effect on the header.php’s <?php echo $body_id; ?>

    Now my <body id=””> and does not valid as xhtml1.1. I should get <body id=”blog”> instead.

    Ah! well, the $body_id variable is not a global, so by the time the get_header gets the header.php, the variable is lost, since it is out of scope.

    Solutions? Well, not many I can think of off the bat. Maybe use some other method to set the body id, like using the is_single() ? functions inside header.php

    bump!

    anyone has found a solution? im trying the same thing without any success…

    declare it as a global variable? that should rid the scope issues….

    hmm. i´ll give it a try.
    thanks for the hint

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Default Kubrick theme & $body_id’ is closed to new replies.
Skip to toolbar