I run quite a few WordPress sites and one of the things I needed to do lately was to get the current page number in WordPress. It can be easily done. To grab the current WordPress page number just use the following.
1 | $pageID = (get_query_var('paged')) ? get_query_var('paged') : 1; |
And that’s all that’s to it. Then of course you can use simple if statement to do all sorts of things. For example, if you only wanted to display something on the very first page (or 2nd, 3rd, 4th, etc) you can do this.
1 2 3 4 5 6 | $pageID = (get_query_var('paged')) ? get_query_var('paged') : 1; if($pageID == 1): // Put your stuff here <h2>This is only displayed on the first page</h2> <p>Wooooo</p> endif; |
Page numbers are simple in WordPress!
Tags: wordpress page numbers




Hey very nice blog!!….I’m an instant fan, I have bookmarked you and I’ll be checking back on a regular….See ya
I don’t know If I said it already but …Excellent site, keep up the good work. I read a lot of blogs on a daily basis and for the most part, people lack substance but, I just wanted to make a quick comment to say I’m glad I found your blog. Thanks,
A definite great read..Jim Bean