WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So my issue is that I need to create two versions of a category.php template. Now, I know very well that if I want to display posts from just one category, I duplicate category.php and call it category-xx.php for the slug or ID number. Great. Got that.

The problem is the client wants it where on the first page of posts, only 4 posts appear. 6 on all subsequent pages. Worse, she wants a div with additional content to appear above the posts but only on the first page. So http://www.yoursite.com/category/whatever/page/2/ and /page/3/ look different than http://www.yoursite.com/category/whatever/.

Now I know I could use conditional comments like is_page() to specify a certain page to display let's say, a certain div. But how would I do it in this sense? Can I do it? There must be some kind of if...else statement that'll make this work.

share|improve this question

get_query_var('paged') will show you pagination information. The code below will show only on first page of archive

if(get_query_var('paged') == 1){
    //run extra code    
share|improve this answer
Works in informational way, but getting non-consistent amount of posts per page correcty is waaay more convoluted. :( – Rarst Jun 25 '13 at 21:23
I actually had the same problem, but since WordPress shows the first page not as ../page/1 but simply as ../, and get_query_var returned 0 on this page, while 2,3,... on all the later pages, I at the end used if (get_query_var('paged') == 0){ /* do first page thing*/} – norbert Oct 8 '14 at 4:41

Your Answer


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.