Title: show code only in part 1
Last modified: August 30, 2016

---

# show code only in part 1

 *  [valtmedia](https://wordpress.org/support/users/valtmedia/)
 * (@valtmedia)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/show-code-only-in-part-1/)
 * i wanna make a php code on my posts. my posts using <!–nextpage–> tag.
    thing
   is, i wanna show this code only in the “page 1” of my posts.
 * Is there a way to do it?
 * Thanks

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

 *  anonymized-13749270
 * (@anonymized-13749270)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/show-code-only-in-part-1/#post-6297084)
 * > thing is, i wanna show this code only in the “page 1” of my posts.
 * How is pagination slug working for your posts?
 * 1. site.com/hello-world/page/1/
 *     ```
       $url = $_SERVER["REQUEST_URI"]/* or get_the_permalink() for single posts*/;
       if(strpos($url,"page/") != '' && strpos($url,"page/1" ) != '')
       	echo "Let's do it!";
       ```
   
 * 2. site.com/hello-world?page=1
 *     ```
       if(!isset($_GET["page"]) || isset($_GET["page"]) && $_GET["page"] == "1")
       	echo "Let's do it!";
       ```
   
 *  Thread Starter [valtmedia](https://wordpress.org/support/users/valtmedia/)
 * (@valtmedia)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/show-code-only-in-part-1/#post-6297086)
 * thanks, but its: 1. site.com/hello-world/1/
 *  anonymized-13749270
 * (@anonymized-13749270)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/show-code-only-in-part-1/#post-6297087)
 * Oh. then maybe this would work:
 *     ```
       global $post;
       $url = $_SERVER["REQUEST_URI"]/* or get_the_permalink() for single posts*/;
       if($url == home_url( '/' ).$post->post_name || strpos($url,$post->post_name."/1" ) != '')
       	echo "Let's do it!"; // do something here, condition: request uri is site.com/hello-world/ or  site.com/hello-world/1/ only, so site.com/hello-world/2/ and other pages are eliminated
       ```
   
 * Let me know how it goes.

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

The topic ‘show code only in part 1’ is closed to new replies.

## Tags

 * [Conditions](https://wordpress.org/support/topic-tag/conditions/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: anonymized-13749270
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/show-code-only-in-part-1/#post-6297087)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
