Title: PHP Header Question/Help
Last modified: August 20, 2016

---

# PHP Header Question/Help

 *  Resolved [akira7799](https://wordpress.org/support/users/akira7799/)
 * (@akira7799)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/php-header-questionhelp/)
 * Hey All,
 * I am new to PHP coding and had a question on how to execute the following two
   requests.
 * 1. I want to have a header.php that will call H2 text from a pool of H2 texts
   at random.
 * For example for:
    <H2>x</H2> <H2>y</H2> <H2>z</H2> <H2>a</H2> could be pulled
   at random when any page is called. What php codes would be able to accomplish
   these requests? If, endwhile, endif statements?
 * 2. Additionally I would only like to display a banner image on the static front-
   page.
    Would something like this work?
 * > <?php if(!is_home() || !is_front_page()) { ?>
   >  HEADER BANNER HERE <?php } ?
   > >
 * Just trying to get an idea of how to tackle this.
 * Any help would be extremely appreciate.
 * Thanks,
    Dave

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/php-header-questionhelp/#post-2624767)
 * > from a pool of H2 texts at random
 *     ```
       <h2><?php
       $input = array(
       "x",
       "y",
       "z",
       "a",
       "b"
       );
       $rand_keys = array_rand($input, 1);
       echo $input[$rand_keys[0]];
       ?></h2>
       ```
   
 * (not tested) more or less the direct example from:
    [http://php.net/manual/en/function.array-rand.php](http://php.net/manual/en/function.array-rand.php)
 * (not primarily a WordPress problem – please try to learn php through web search
   and web tutorials)
 * > display a banner image on the static front-page
 *     ```
       <?php if( is_front_page() ) { ?>
       HEADER BANNER HERE
       <?php } ?>
       ```
   
 * [http://codex.wordpress.org/Function_Reference/is_front_page](http://codex.wordpress.org/Function_Reference/is_front_page)
 *  Thread Starter [akira7799](https://wordpress.org/support/users/akira7799/)
 * (@akira7799)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/php-header-questionhelp/#post-2624818)
 * alchymyth,
 * Thank you kindly for your reply. The header banner worked perfectly.
 * I did some searching on the php.net/manual site and am learning quite a bit. 
   However, I had one more question in regards to the array. How do you activate
   the is_front_page tag to work on FALSE boolean searches. That is, if the page
   is NOT the front_page I would like the following to return. This code works, 
   but will apply to all pages, even the front_page, where two H2 headers would 
   show up, and I only want one.
 *     ```
       <h2 class="intro">
       <?php
       $input = array("...because the little things make a difference.", "...because there’s always one more thing to do.",
       "...because we listen to your wishes.",
       "...because we can make your day perfect.");
       $rand_keys = array_rand($input, 2);
       echo $input[$rand_keys[0]] . "\n";
       ?>
       </h2>
       ```
   
 * I tried the following. It supplies a return of an empty H2 section. as if it 
   is the front_page, when it is not:
 *     ```
       <h2 class="intro">
       <?php if( is_front_page(FALSE) ) {
       $input = array("...because the little things make a difference.", "...because there’s always one more thing to do.",
       "...because we listen to your wishes.",
       "...because we can make your day perfect.");
       $rand_keys = array_rand($input, 2);
       echo $input[$rand_keys[0]] . "\n"; } ?>
       </h2>
       ```
   
 * Again, please just direct me to a place to look, because I’m not sure of the 
   terminology for which to search.
 * Also, is there a php syntax checker?
 * Thanks,
    Dave
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/php-header-questionhelp/#post-2624832)
 * >  if the page is NOT the front_page
 * `if( !is_front_page() )`
 * again a fundamantal php problem…
 * [http://php.net/manual/en/language.operators.logical.php](http://php.net/manual/en/language.operators.logical.php)
   
   [http://www.w3schools.com/php/php_operators.asp](http://www.w3schools.com/php/php_operators.asp)
 * alternative:
 *     ```
       <?php if( is_front_page() ) : ?>
       do one thing for the front page
       <?php else : ?>
       do something else on NOT front pages
       <?php endif; ?>
       ```
   
 *  Thread Starter [akira7799](https://wordpress.org/support/users/akira7799/)
 * (@akira7799)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/php-header-questionhelp/#post-2624835)
 * Thanks again. if( !is_front_page() ) worked like a charm.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘PHP Header Question/Help’ is closed to new replies.

## Tags

 * [Coding](https://wordpress.org/support/topic-tag/coding/)
 * [header](https://wordpress.org/support/topic-tag/header/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [akira7799](https://wordpress.org/support/users/akira7799/)
 * Last activity: [14 years, 3 months ago](https://wordpress.org/support/topic/php-header-questionhelp/#post-2624835)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
