How to detect current archive page
-
I am trying to code my archive pages to show different HTML depending on what page of the archive you are on.
For example, if you were to view the archive “Family News”, the first page URL might look something like this:
https://www.example.com/category/family_news/
Clicking on the “next page” link would take you to:
https://www.example.com/category/family_news/page/2/
What PHP code would allow me to detect if I am on the first page of an archive?
Some information about my setup: Under Options > Reading, I setup my blog to “Show at Most 1 Posts”. I am using the default archive template (archive.php) with one exception — I added the following line of code before The Loop to sort my posts by date ascending:
<?php $posts = query_posts($query_string . '&orderby=post_date&order=asc'); ?>
- The topic ‘How to detect current archive page’ is closed to new replies.