Support » Theme: Portfolio Press » [Theme: Portfolio Press] I want to add some text to the home page header only

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi.
    The problem with your code is that you can’t access post information while in the home page. The way WP works is that, when you are in the home page, you are not inside a post, so the post data is not accessible.
    What you could do is have one header for your home page and one for your posts. Something like this in your header.php file would work:

    <?php
    if( is_home() ) {
       $header = '<p>We are Home</p>';
    } else if( is_single() ) {
       $header = '<img src="path/to/image" alt="image" />'
    } else {
       $header = '<p>Default Header</p>';
    }
    echo $header;
    ?>

    If you only need a custom header for your home page only and the same header in the rest of the site, simply remove the else ifpart of the code:

    <?php
    if( is_home() ) {
       $header = '<p>We are Home</p>';
    } else {
       $header = '<p>Default Header</p>';
    }
    echo $header;
    ?>

    Another simpler alternative for this last version would be:

    <?php
    $header = ( is_home() ) ? '<p>We are Home</p>' : '<p>Default Header</p>';
    echo $header;

    Thread Starter figure2

    (@figure2)

    @marventus: Before I test your solution I need some info. Basically what I need is the default header with the addition of one line of text after the description. If I read your solution with my limited PHP knowledge, it looks like it replaces the entire header with one line of text which does not solve my problem.

    Can I insert this code inside the hgroup, leaving all the content which is there now intact with the addition of my line of text only on the home page?

    Here is what I am looking to do (Before and after shots): http://www.markhannondesign.com/clientJobs/homePage.jpg

    <?php if (is_front_page())echo 'This text can only be seen on the home page.'; ?>

    Hi, I’m NEW and can’t even get a template downloaded…can anyone tell me how to do that? I can only open NOT save or Download.THANKS.susan

    Thread Starter figure2

    (@figure2)

    Thanks Srikat!

    @figure2: Did you figure out where to insert the code? If you didn’t, I’ll download your theme and tell you where to put it.

    Thread Starter figure2

    (@figure2)

    @Marventus: Srikat’s code solved the problem. Thanks for the offer of help though.

    Mark

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Theme: Portfolio Press] I want to add some text to the home page header only’ is closed to new replies.