• Resolved Uberche

    (@uberche)


    I know this has been asked and I’ve gone through the other pages as well as many pages of people’s blogs explaining but it’s still not working. In fact I had it working once but I ruined it through stupidity on my part and can’t for the life of me figure out what I did last time. So here we go…

    I have a website (https://www.ethansenglishcafe.com) where I am using WordPress for publishing a blog and the header has buttons, i want the button for the page currently being used to be a different colour. I’ve tried a couple different ways to no success (except once as I said).

    So the header.php file has the code above and then it comes to

    <?php wp_head();?>
    </head>
    <body <?php body_class(); ?>>
    *header CSS code is here*
    <hr />

    So I tried
    <?php
    if (is_page(‘forum’)) {
    *forum header CSS code*;
    }
    else {
    *Default CSS code*;
    }
    ?>

    But when i load the page it wont load, just a white screen, nothing loads. I also tried to get more specific, the code I actually want to change is the buttons so I tried

    <?php
    if (is_page(‘forum’)) {

    <li><a class="current" href="*forum url*"><span>forum</a></li>
    ;
    }
    else {

    <li><a href="*forum url*"><span>forum</a></li>
    ;
    }
    ?>

    which of course also didn’t work and returned a empty white page. Next I tried another technique I saw on a blog which was creating different Header pages for example “headerforum.php” and using the code below in the regular header.php to tell which one to load

    <?php
    if (is_page(‘slider’)){
    include(TEMPLATEPATH.’/headerslider.php’);
    }
    elseif (is_page(‘blog’)){
    include(TEMPLATEPATH.’/headerblog.php’);
    }
    else {
    include(TEMPLATEPATH.’/headerdefault.php’);
    }
    ?>

    But also gave a plain white page. I’ve been playing with this for far longer than I’d like to admit and am a little frustrated, any help?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter Uberche

    (@uberche)

    Is it just me or is my question apparently not showing?

    Different headers in different pages.

    <?php
    if (is_page('slider')){
    	include(TEMPLATEPATH.'/headerslider.php');
    }
    elseif (is_page('blog')){
    	include(TEMPLATEPATH.'/headerblog.php');
    }
    else {
    	include(TEMPLATEPATH.'/headerdefault.php');
    }
    ?>

    made the corresponding header.php files and it still gives me a white empty page.

    tried

    <?php
    if (is_page('forum')){
    	*forum header CSS code*;
    }
    elseif (is_page('blog')){
    	*blog header CSS code*;
    }
    else {
    	*regular header CSS code*;
    }
    ?>

    and also just empty white pages.

    It’s not showing. That happens sometimes…… not sure why. My replies have been known to disappear

    Thread Starter Uberche

    (@uberche)

    Updated my reply with the question. seems to be showing. I’ve checked all sorts of sites for the code for this and none of it seems to be working for me… not sure why. Hoping someone here can answer because I’m not much for php so I’m stumped.

    it’s showing now… strange.

    Sometimes posts get caught up in the spam queue, when that happens an admin unmarks the post/thread (if deemed appropriate)..

    If a post/thread doesn’t show, just be patient and it will appear once an admin gets to it.. ??

    the active/current tabs have a pair of background images:
    https://www.ethansenglishcafe.com/Images/topmenu-active-r.gif
    https://www.ethansenglishcafe.com/Images/topmenu-active-l.gif

    1.
    to have different current tab colors for the different pages, you would need to make more sets of these images, in different colors.

    2.
    most of your code snippets look ok, so i assume you tried to add them in a wrong place; you would also probably have had some error messages with your blank screen (?)

    3.
    you would need to introduce some individual id or class in these pages to make them distinguishable for css; body_class() might be an option:
    https://codex.www.ads-software.com/Template_Tags/body_class

    4.
    you could then use this individual class to style the current link tab:
    as a variation of these styles:

    #topmenu ul li a.current {
            color: #000;
            font-weight: bold;
            background: #fff url(Images/topmenu-active-l.gif) 0 0 no-repeat;
        }
    
        #topmenu ul li a.current span {
            display: block;
            width: auto;
            background: #fff url(Images/topmenu-active-r.gif) 100% 0 no-repeat;
        }

    Thread Starter Uberche

    (@uberche)

    1. I should have been a little clearer I think, I only want two different styles of buttons, the brown and the silver. Both are working fine on the server. What I want is the current page’s button to be silver and the rest brown. Right now all buttons using wordpress pages (Blog, Fantastic Phrase and Forum) all have the Blog silver because that’s the base page.

    So I basically need to use conditional statements to make them change, when it’s looking at the Fantastic Phrase archive I want the Fantastic Phrase button silver, when they are looking at the Forum I was the forum button Silver.

    2. Ok, so where exactly in the default word press php file should they be placed?

    3 & 4. But they are all in wordpress so it only has one page, so CSS styles don’t work in this case. Half my site is made using regular CSS styled pages and they work fine. half is built around wordpress as a content manager and I’m having trouble getting the buttons to work in that.

    could you paste a copy of your header.php into a pastebin .

    it is easier to talk about how to change things when seeing how it is so far.

    btw: most buttons are working in the active state, only ‘forum’ is not showing the active state -showing ‘blog’ instead.

    Thread Starter Uberche

    (@uberche)

    My header in pastebin

    There are two buttons not working so far, the header is designed so Blog works, Forum isn’t working, it’s a Simplepress forum within WordPress on it’s own page and Fantastic phrase is not working either, it’s just the category “fanphrase” within wordpress.

    Either conditional statements within the code for each of the three buttons or conditional statements with three separate codes would be fine. All that needs to change is which of the three buttons (Fantastic phrases, Blog and Forums) has the “Class=”current”” depending if I’m looking at the Page ‘forum’, the category ‘blog’ or the category ‘fanphrase’.

    Thanks!

    ‘fantastic’ seems to get redirected to a html page, and imho shows the current state properly.

    for ‘blog/forum’ try to change these two lines:

    <li><a class="current" href="https://www.ethansenglishcafe.com/wpblog/?cat=24"><span>Blog</span></a></li>
                            <li><a href="https://www.ethansenglishcafe.com/wpblog/?page_id=30"><span>Forum</span></a></li>;

    into this:

    <li><a <?php if(is_category('24')) { echo ' class="current"'; } ?> href="https://www.ethansenglishcafe.com/wpblog/?cat=24"><span>Blog</span></a></li>
                            <li><a <?php if(is_page('30')) { echo ' class="current"'; } ?> href="https://www.ethansenglishcafe.com/wpblog/?page_id=30"><span>Forum</span></a></li>;

    Thread Starter Uberche

    (@uberche)

    Fantastic should also be, maybe just needed reloading (I just updated it to the proper link this afternoon after you replied here). But regardless just used the code you put here on the Fantastic link as well and worked like a charm!!

    Thanks a lot Alchymyth! So much less hassle than I was trying to make it.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Different headers in Different Pages’ is closed to new replies.