WordPress: need help with PHP, will pay the first person who posts an answer

Discussion in 'PHP' started by Jeffr2014, Apr 2, 2014.

  1. #1
    Hi,
    I have WordPress blog where I slightly customized the theme. I now have the following HTML fragment inside header.php:
    <div class="container11" >
    <div class="row" id="header" >
    <div class="column12 alpha" id="header-1" >
    <h1>Some nice header text</h1>
    <h2>Some other text</h2>
    </div>
    <div class="column3 omega" id="header-2"></div>
    </div>
    </div>

    Instead, I need to have the following behavior:
    if the header is loaded in the homepage or in the post I need to have "<h2>some text that is good for posts or homepage"</h2> and if it is loaded in the page (as opposed to post) I need to have <h2>some text that is good for pages"</h2>

    I know that it is really easy to do with PHP but don't have time to recall it or to look up. The first person, who posts an answer (i.e. code fragment that works after I replace with it the HTML fragment above), will receive $10 "thank you" payment over PayPal.

    Thanks all,

    Jeff
     
    Solved! View solution.
    Jeffr2014, Apr 2, 2014 IP
  2. #2
    <div class="container11" >
        <div class="row" id="header" >
            <div class="column12 alpha" id="header-1" >
                <h1>Some nice header text</h1>
                <?php
                if ( is_page() )
                    echo '<h2>some text that is good for pages</h2>';
                elseif ( is_home() || is_single() )
                    echo '<h2>some text that is good for posts or homepage</h2>';
                ?>
            </div>
            <div class="column3 omega" id="header-2"></div>
        </div>
    </div>
    PHP:
    my paypal id:
     
    Last edited: Apr 2, 2014
    bhuthecoder, Apr 2, 2014 IP
  3. Jeffr2014

    Jeffr2014 Active Member

    Messages:
    254
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    55
    #3
    Thank You. Your code worked fine, so I will send "thank you" payment to you. The "contest" is now closed.
     
    Jeffr2014, Apr 3, 2014 IP