The WP_Query
object contains a max_num_pages
field which contains how many pages of posts there are. You can compare the current page number with it. (This is how get_next_posts_link()
does it.)
global $wp_query;
$current_page = $wp_query->get( 'paged' );
if ( ! $current_page ) {
$current_page = 1;
}
if ( $current_page == $wp_query->max_num_pages ) {
// You are on the last page
}
Related Posts:
- Loop with Dynamic Categories
- Remove child products from woocommerce category page [closed]
- Listing all posts from current category on page
- How to insert category list into post creation page, and retrieve chosen categories?
- Getting the Most Recent Posts from Multiple Categories
- Template category.php with page (no posts)
- Get the children of the parent category
- Should category.php and The Loop be used if the query needs to be customizable?
- Exclude the category from the WordPress loop
- How do I get the category URL from get_the_category?
- get_field not displaying my custom field value
- Default WP Gallery – show only galleries of a certain category
- Rearranging posts based on categories
- WP_Query not looking at child category
- Randomise results from a category page?
- Get page content by category or tag
- Display all posts in category, with specific tag posts at top
- Show div only if post is in specific category
- How to show a category post to a specific registered user
- Display list of Sub-Categories and the posts they contain, within one main Category
- Category page showing posts from all categories
- How can I create a loop to build slides based on multiple categories using Coda Slider
- Create a full width responsive header image per page
- Get a list of commas separated categories inside a loop
- Using same slug name for a page and category
- Categories list loop – add separator every year
- How would you create a “weekly” archive?
- Remove “Category Archives: title” at the top of a category page [duplicate]
- How to exclude categories from recent posts, recent comments & category widgets?
- How to have a static category/author page?
- I use same slug name for category and page
- Page with the same name of a category
- Display one latest post from multiple categories
- How do I get the total number of categories in a list of search results?
- Check if post belongs to any category
- Show posts of category in a page
- How do I display the posts from a custom post type on a category.php page?
- Show pages and articles in category search result
- How to group the loop posts in a particular by author?
- How to create taxonomy values for pages and list them in wp-admin
- Display products for a category, sorted by post_excerpt
- What type of page should i use? static page or category page? and what’s the difference? [closed]
- Exclude category from loop not working
- Listing Parent, Child and GrandChild Categories and then the PostTitles on Page Template !
- Duplicate Category and Page URL loads Category instead of the Page
- Category archive page – loop through posts of certain tag (with pagination) – pre_get_posts
- Add a specific category at a specific place to the menu that uses wp_list_pages
- If newest post of category is newest post in general, skip first post of category
- a-z list, categories and sub categories in loop
- Viewing category pages without the word ‘category’ in URL
- in_category() works in single.php but not in page.php?
- Why would in_category only return one post in a specific category?
- Is it possible to select and edit the way the most recent post from a certain category is displayed on the page?
- Categories vs. Page Site Organization
- How do I automatically put categories and their descriptions on a WP Page?
- Displaying multiple loops based off of category
- How to loop only categories without posts (+ show category featured image with acf) [closed]
- Additional featured post on first page
- editing fonts of category links from the_category() funtion
- Is it possible to restrict viewing of category PAGE to logged in users only?
- Show all posts for a specific category/author
- Redirect category to url with /category
- create a page which displays a list of categories title+ short description?
- Enter a variable in the ‘category_name’ parameter
- Second level subcategory
- how to define category loop last class in the third
- Hard coded main navigation
- Query Posts Exclude Entire Category
- How to make 2 tag feeds show up on 1 page?
- Class active for Archive link – looped out
- Taxonomy name repeating when showing 2 posts from each category
- Search in custom post type AND in pages with category
- Display the last post by each category?
- Remove product category placeholder image (Woocomerce)
- posts_nav_link(); picks up index.php instead of category.php as template
- WooCommerce – How to show specific category first-rest of products-specific category last
- Give a page priority over a category that has the same name?
- Multiple URL’s based on category for one post
- Counter in loop in foreach
- category permalinks
- How to “group” (categorize) the Pages together?
- Multiple Loops on category.php with pagination on last loop
- How to exclude the last post from a category(featured for example) from the main loop?
- Different banner for different section
- Custom category URL rewriting
- Putting a Category of posts under a Page
- Order by category titles
- How can you change the permalink for pages?
- ajax for filtering posts by category in wordpress loops
- Inside a loop, how to change CSS class based on category name?
- Exclude current post from loop
- Should I use “Categories ” or “Pages” for a WordPress Static Site (A non blog site)?
- Category.php loads first before page.php?
- Categories list loop – add separator every 3 categories [closed]
- How do I display something on a particular category page?
- Limit get_categories to show each category once
- Automatically redirect a page to a category that share the same slug
- Display single category name in woocommerce loop
- How to create a subcategory to a PAGE on WP?
- Get the ID of 10 Latest Pages stored in a WordPress Category