WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Header only showing on index and not on posts... (4 posts)

  1. thestormtrooper
    Member
    Posted 7 years ago #

    Hi,

    I'm using a randomize plugin from: http://andersdrengen.dk/projects/randomize/

    This seems to work perfectly with my index pages and search pages etc. For some reason though when you click on a post I've made no header at all shows up?

    Can anyone point me in the right direction as to how to solve this? It's doing my head in!?

    I have noticed that the generated pages for the index have the following style produced when I view the source:

    <style type="text/css" media="screen">
    #header { background: url("http://www.stuartjackson.co.uk/v1/blog/wp-content/themes/default/images/header10.jpg") repeat-y top; border: none; }
    </style>

    Whereas the pages for the posts has the following that doesn't work:

    <style type="text/css" media="screen">
    #page { background: url("http://www.stuartjackson.co.uk/v1/blog/wp-content/themes/default/images/kubrickbgwide.jpg") repeat-y top; border: none; }
    </style>

    Basically I want the post pages to produce the same as the index etc as first example. The random function changes the image to header01.jpg or header09.jpg etc etc...

    Header code is as follows if this helps:

    <!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">

    <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() ) { ?> » 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() ) {
    ?>
    #header { background: url("<?php randomize(header) ?>") 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" onclick="location.href='index.php'" title="Return to Homepage!" style="cursor: pointer;">
    <h1>/"><?php bloginfo('name'); ?></h1>
    <div class="description"><?php bloginfo('description'); ?></div>
    </div>
    </div>
    <hr />

    Any help is greatly appreciated as is any other site comments or recommendations.

    http://www.stuartjackson.co.uk/v1/blog/

    Thanks
    Stuart

  2. yosemite
    Member
    Posted 7 years ago #

    I suspect it is the following line in your header.php:
    if ( !$withcomments && !is_single() ) {
    ?>
    #header { background: url("<?php randomize(header) ?>") repeat-y top; border: none; }

    It is only executing the randomize() if it is NOT '$withcomments and NOT 'single'.

    Since that bit is really about the whether the sidebar should be there or not, you might want to move the randomize call out of that if/else function.

    Hope this makes sense...

  3. thestormtrooper
    Member
    Posted 7 years ago #

    ok lost...

    i'm not too crash hot with this stuff...

    if the randomize isn't to be in that section do you know where i'd put it?

    Just so badly want to get this sorted.

    your help is greatly appreciated.

    Cheers Stu

  4. thestormtrooper
    Member
    Posted 7 years ago #

    ok...

    just thought i'd let you know... i seem to have solved it. thanks for your prompt in the right direction.

    I have now placed the line of code:

    #header { background: url("<?php randomize(header) ?>") repeat-y top; border: none; }

    where it is at the moment and also just after the end of the sidebar section and it seems to have solved the problem. If I only have the code once it is only displayed in one page or the other but the two lines of code seem to display it everywhere!

    sorted!!?

    Thanks again.
    Stu

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags