WordPress.org

Ready to get started?Download WordPress

Forums

Custom Headers and SideBars? (11 posts)

  1. FireFox
    Member
    Posted 7 years ago #

    Hello

    I know how to make custom posts for categories but how do you create it for headers and sidebars?

    I tried the same technique for custom posts - that is using an index/single page and renaming it to a category (ex. category-28.php).

    any suggestions?
    thank you so much..

  2. moshu
    Member
    Posted 7 years ago #

    I know how to make custom posts for categories

    hmmm... I don't.
    You can create custom templates for categories, eventually.

    Try to describe accurately your desired end result ;)

  3. FireFox
    Member
    Posted 7 years ago #

    Basically, I would like a custom header (with it's own img or masthead) for different pages --

    for example, the Contact Us page will have its own separate header than from the Index page.

    The same can be said for custom sidebars.

    I'm not sure what the technique is to create them.

    thanks..

  4. moshu
    Member
    Posted 7 years ago #

    It can be done, using the conditional tags:
    http://codex.wordpress.org/Conditional_Tags

    If you change only the so-called header image, you can use a series of conditionals in the header.php and you are all set.

    If you need to change more than just the imaage, you'll probably go with custom Page templates calling different header template file, e.g. header2.php
    Use this line (literally!)
    <?php include (TEMPLATEPATH . '/header2.php'); ?>

    The same would go for the sidebars:
    either use a conditional in the Page template(s) to determine which sidebar you want, or call the approrpiate sidebar2.php, sidebar3.php etc. with the code line above.

  5. FireFox
    Member
    Posted 7 years ago #

    Thank you very much Moshu!

    it worked.

    for anyone else who come across this problem, this is what you should put in your header (provided that in your style.css, you have "masthead" as the container for your header image):

    <div id="masthead"
    <?php if ( is_page(40))
    {
    echo 'style="background:url(http://www.yourdomainname.com/images/contactusbanner.jpg);"';
    }
    ?>
    >

  6. pufftenticle
    Member
    Posted 7 years ago #

    Hello, Sorry to bring this one back up, but I am not understanding something.

    I am wanting to do the same thing, and I understand that the answer for this is all over the Codex and the Forums, I have read all of them and just can't seem to get them to work.

    I have a conditional in my 'sidebar' file that says:

    <?php if (is_home()) : ?>

    and then there is a 'column three' that makes the index page a 4 column layout with all of the other pages being 3 column.

    What I am trying to do is leave the left sidebar alone and make a different right sidebar for each of the categories (12 of them). I have an individual template for each category (using the 'category-x.php' method) because we will be styleing each of the 12 categories much differently than each other. As such, we would like a custom right sidebar for each, but leave the left sidebar alone.

    Everytime I try to place the conditional in the 'sidebar.php' file, it gives an error on both the index and the category page. don't I need 12 sidebars and a conditional in each category template page ?

    Thanks in advance ...

  7. pufftenticle
    Member
    Posted 7 years ago #

    practiced, studied hard, and fig'd it out. no i don't need 12.

  8. plastictabs
    Member
    Posted 7 years ago #

    You should really post your findings. It would help others in the community who have the same issue.

  9. JMershon
    Member
    Posted 7 years ago #

    Please do post it - I also would like to see the solution.

  10. pufftenticle
    Member
    Posted 7 years ago #

    Sure ! sorry, i'm not used to being asked; i'm usually the asker (is that a word?)

    it was actually real easy, and i'm not sure if this is the most efficient way to do it, but this is what i did:

    1) Each of the 12 categories got their own template called category-1.php, category-2.php, etc.
    2) In the template, i used this:

    <?php include (TEMPLATEPATH . '/leftsidebar.php'); ?>

    which is from the regular page and index templates. However, I created two new sidebars called 'leftsidebarpage.php and rightsidebarpage.php' and called those on each of the category templates

    3) I went back in and installed information that was unique to that category on the template 'sidebars'.

    4) When the time comes and information that is completely unique needs to be in one of the sidebars, then i can create 'rightsidebarpageREGIONX.php' and call it

    it is still very much under construction, but here is a look at it: Texas-Fire.com (check the 'Regional Information' links to see each of the categories). right now the right sidebar (which is what got me started on this) has Google ads in it, but that will be replaced with the unique information for each category (region)

  11. ramblinscribe
    Member
    Posted 7 years ago #

    Wow, Puff, I'm impressed. With much anguish I learned a little about (x)html and CSS, now I tackle WordPress PHP! I've been beating my head against the wall for a couple weeks and finally managed to get some pages/a simple blog up and running!
    Congratulations. I'm bookmarking this thread.
    Sylvia

Topic Closed

This topic has been closed to new replies.

About this Topic