Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to find a template page (or conditional statement) that will target:

http://url.com

but not

http://url.com/page/2/

home.php and front-page.php seem to target both. The front page displays my latest posts.

Thanks in advance!

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

WordPress provides is_paged() which returns true on any archive or blog that stretches over multiple pages. This isn't what you want, but the is_paged Codex article tells us where to go:

If you need to check which page of the blog you are on, you can look in $wp_query->query_vars['paged']. Remember that inside functions you might have to global $wp_query first.

So, you should be able to use this snippet to only show something on the first page:

global $wp_query;
$my_paged_page = $wp_query->query_vars['paged'];
if ( $my_paged_page == 1 ) {
    // do something
}
share|improve this answer
    
Thanks for the tip! is_paged(); was exactly what I needed. –  Andrew Carreiro May 27 '12 at 19:08
    
Great. Make sure to read the Codex as it seemed from your question that is_paged() would return TRUE on both the example URLs you listed. –  mrwweb May 27 '12 at 19:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.