Forums

Different header image on About Page (22 posts)

  1. riasaurusrex
    Member
    Posted 3 years ago #

    Does anyone know if it is possible to have a different header image display on, say my about page, than the main page? And/or how to do this?

    Thank you.

  2. t31os
    Member
    Posted 3 years ago #

    <?php if(is_page('About')) : ?>
    do about page specific code
    <?php else : ?>
    do normal stuff
    <?php endif;?>

    Would need to see your existing code to be more specific...

    header.php more then likely..

    If posting code, please do so inside backticks as indicated in the post box or use a pastebin...
    http://wordpress.pastebin.ca/

  3. riasaurusrex
    Member
    Posted 3 years ago #

    Here's the full header.php

    http://wordpress.pastebin.ca/1390624

  4. lhoylhoy
    Member
    Posted 3 years ago #

    sure you can. first you have to create new page template. to do that copy everything inside your index.php then create a new php file and name it any name you prefer then paste every you just copied. insert this code above your new php file:

    <?php /* Template Name: ANY NAME YOU PREFER
    */ ?>

    save it.

    then go to your dashboard>>pages>>add new>>your page's name in your case it's about

    at the right side under the attribute there is a dropdown list label PARENT choose your template name then save it.

    going back to your new php file you can now edit your page!

  5. riasaurusrex
    Member
    Posted 3 years ago #

    Is this all I need at the top of the newly created page (aside from all the code from the index.php that i copied and pasted)?

    <?php about ?>

    It's not showing up in the drop down menu under pages.
    All that is showing is 'Main Page (no parent)'.

    Thanks for helping me out.

  6. lhoylhoy
    Member
    Posted 3 years ago #

    <?php /* Template Name: ANY NAME YOU PREFER
    */ ?>

    just change 'ANY NAME YOU PREFER' so it will become

    <?php /* Template Name: about
    */ ?>

  7. riasaurusrex
    Member
    Posted 3 years ago #

    You're a rockstar, thank you so much!

  8. lhoylhoy
    Member
    Posted 3 years ago #

    you're welcome

  9. riasaurusrex
    Member
    Posted 3 years ago #

    So, now it shows up under the templates drop down, but I get this message when I go to the page:
    Parse error: syntax error, unexpected T_STRING in /home/planpla9/public_html/blog/wp-content/themes/atahualpa/about.php on line 1

  10. lhoylhoy
    Member
    Posted 3 years ago #

    i thought you're good now hehe, anyway if you're sure you pasted the code above, really above no other code before

    <?php /* Template Name: about
    */ ?>

    then there might be unnecessary characters there. check...
    paste the exactly the same as above same lines you have two lines there if you noticed.

  11. riasaurusrex
    Member
    Posted 3 years ago #

    got it.
    thank you.
    again.

    One more question, any idea why the styling in a sidebar text box widget would render fine on the index page and not the about page?

  12. lhoylhoy
    Member
    Posted 3 years ago #

    that's impossible since you just duplicated the index file right? try to repeat the process

  13. riasaurusrex
    Member
    Posted 3 years ago #

    hrumph...not sure what to do now to override the what's set for the header on the main page

  14. lhoylhoy
    Member
    Posted 3 years ago #

    hey don't worry just delete your about php file and do it again maybe you just had a little error editing it.

  15. riasaurusrex
    Member
    Posted 3 years ago #

    Well, I have the new 'about' template working and what not. I'm just not sure how to go about changing the header image since it's rendered through the theme options php. I'm pretty clueless with PHP, if you haven't noticed...

    thanks.

  16. lhoylhoy
    Member
    Posted 3 years ago #

    i understand here is what you should do, go to your about.php then find this code <?php bloginfo(template_directory);?>your image url(where your image is located). then upload your new header image(should be .png .jpg or .gif format) to the same directory.replace your old header image with your new one to you php file

  17. riasaurusrex
    Member
    Posted 3 years ago #

    That code is located in the header.php file.
    Should I make a new header.php file (named aboutHeader.php or something like that) and make the change in that file then?

    If so, where/how do I change which header file the about.php file links to?

  18. lhoylhoy
    Member
    Posted 3 years ago #

    oh my gosh! i'm sorry i was thinking your header image is located in your index.php i realized its in the header.php. Bear with me ok its gonna be more complicated.

    this is what you are gonna do:

    1. duplicate your header.php save it as customheader.php then replace your old image with your new one (make sure you uploaded the actual image file to the same directory) with the last code I gave you. hope this one's clear...
    2. for your question how to link it with your about.php, open the file (about.php) then replace <?php get_header();?> with <?php get_customheader();?>

    note: <?php bloginfo('template_directory');?>old image directory becomes <?php bloginfo('template_directory');?>new image directory. Just upload your new image file to the same directory as your old image file so you can just edit the file name not the whole directory or subdirectory ok?

    good luck!

  19. t31os
    Member
    Posted 3 years ago #

    Seems alot of hard work for something so basic...

    Why not just simply do this to your header element in the header.php...
    <?php if(is_page('About')) : ?>class="aboutpageclass"<?php else : ?>class="normalclass"<?php endif;?>

    Which simply switches a class on a element, usage would be like so..

    Example element..
    <div id="header">

    With code added..
    <div id="header" <?php if(is_page('About')) : ?>class="aboutpageclass"<?php else : ?>class="normalclass"<?php endif;?>>

    Then in your CSS apply style to the necessary classes, following the example above, something like....

    Example..

    .aboutpageclass { background-image:someimage.jpg; }
    .normalclass { background-image:anotherimage.jpg }

    Why go through the work of creating a template/page and fiddling with function calls when it's such a simple and straight-forward task. Not saying the above is 'wrong' per say, but i don't think it need be that much work...

  20. riasaurusrex
    Member
    Posted 3 years ago #

    yeah, i like that idea.
    thanks.

  21. SiberianSiren5
    Member
    Posted 2 years ago #

    lhoylhoy,

    I tried using your idea of designing a custom page template himalayas.php and a custom header which I called himalayaheader.php. I tried directing this to a new directory himalaya_images.

    Now I get this error:
    Fatal error: Call to undefined function: get_himalayaheader() in /home/armst5/public_html/MyBlog/wp-content/themes/atahualpa.3.2/atahualpa/himalayas.php on line 14

    What am I doing wrong? The header needs to be directed to a folder that contains several rotating images.

  22. pavlos1982
    Member
    Posted 2 years ago #

    i have done this and it works but i want to add it to more pages how to i add another piece of php code for other pages from this code

    <div id="header" <?php if(is_page('About')) : ?>class="aboutpageclass"<?php else : ?>class="normalclass"<?php endif;?>>

    Then in your CSS apply style to the necessary classes, following the example above, something like....

    Example..

    .aboutpageclass { background-image:someimage.jpg; }
    .normalclass { background-image:anotherimage.jpg }

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags