Title: Basic PHP Question (Pagination)
Last modified: August 20, 2016

---

# Basic PHP Question (Pagination)

 *  [nickaster](https://wordpress.org/support/users/nickaster/)
 * (@nickaster)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/basic-php-question-pagination/)
 * Hi there. I have a pretty standard wordpress front page with pagination at the
   bottom so I can go to page 1, 2, … to infinity.
 * All the pages look pretty much the same.
 * How can I put a switch on certain pages to do something different? IN other words:
 * “If this is page 2, show this bunch of HTML” .. or “If this is not page 3-infinity”
   then put the word “FOO” in this location.
 * Might someone know the basic PHP do to that?
 * THANKS!

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

 *  [Chip Bennett](https://wordpress.org/support/users/chipbennett/)
 * (@chipbennett)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/basic-php-question-pagination/#post-2530840)
 * Try using the `$paged` global variable. e.g.:
 *     ```
       <?php
       global $paged;
       if ( $paged && '2' == $paged ) {
           // We're on Page 2;
           // do something
       }
       ?>
       ```
   
 *  Thread Starter [nickaster](https://wordpress.org/support/users/nickaster/)
 * (@nickaster)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/basic-php-question-pagination/#post-2530953)
 * Thanks …
 * Dumb question perhaps, but what are the // for? That means a comment inside php
   right? If I try to put HTML there it kills the whole page, what’s the right way
   to code HTML in that area?
 *  [Chip Bennett](https://wordpress.org/support/users/chipbennett/)
 * (@chipbennett)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/basic-php-question-pagination/#post-2530954)
 * > If I try to put HTML there it kills the whole page, what’s the right way to
   > code HTML in that area?
 * You have to _close the PHP tag_, add your HTML, then _open a new PHP tag_:
 *     ```
       <?php
       global $paged;
       if ( $paged && '2' == $paged ) {
           // We're on Page 2;
           // do something
           ?>
           <!-- HTML GOES HERE! -->
           <?php
       }
       ?>
       ```
   
 *  Thread Starter [nickaster](https://wordpress.org/support/users/nickaster/)
 * (@nickaster)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/basic-php-question-pagination/#post-2530955)
 * Ah… easy, thanks!

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

The topic ‘Basic PHP Question (Pagination)’ is closed to new replies.

 * 4 replies
 * 2 participants
 * Last reply from: [nickaster](https://wordpress.org/support/users/nickaster/)
 * Last activity: [14 years, 3 months ago](https://wordpress.org/support/topic/basic-php-question-pagination/#post-2530955)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
