Default Kubrick theme & $body_id (7 posts)

  1. Proton
    Posted 11 years ago #

    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.

  2. carthik
    Posted 11 years ago #

    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.

  3. Proton
    Posted 11 years ago #

    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.

  4. carthik
    Posted 11 years ago #

    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

  5. mr1973
    Posted 11 years ago #


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

  6. DarkCryst
    Posted 11 years ago #

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

  7. mr1973
    Posted 11 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.