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)
- Should category.php and The Loop be used if the query needs to be customizable?
- Exclude the category from the WordPress loop
- get_field not displaying my custom field value
- Rearranging posts based on categories
- Randomise results from a category page?
- Show div only if post is in specific category
- How to show a category post to a specific registered user
- Create a full width responsive header image per page
- Get a list of commas separated categories inside a loop
- Display one latest post from multiple categories
- How do I get the total number of categories in a list of search results?
- Show posts of category in a 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
- a-z list, categories and sub categories in loop
- Viewing category pages without the word ‘category’ in URL
- Is it possible to select and edit the way the most recent post from a certain category is displayed on the 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
- 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
- Hard coded main navigation
- Query Posts Exclude Entire Category
- WooCommerce – How to show specific category first-rest of products-specific category last
- Multiple URL’s based on category for one post
- category permalinks
- Custom category URL rewriting
- Inside a loop, how to change CSS class based on category name?
- Exclude current post from loop
- Categories list loop – add separator every 3 categories [closed]
- How do I display something on a particular category page?
- How to create a subcategory to a PAGE on WP?
- Get the ID of 10 Latest Pages stored in a WordPress Category
- How to show 5 posts from specific category on related page?
- Trying to get variables in hacked category dropdown
- category__not_in and id values from variable
- How to put page numbers with the next/previous on a post/category list?
- How can I display tags as categories?
- Do not show sub categories in the loop on archive-product.php
- Allow user to select categories that will display in post loop
- Insert HTML content in WP Query at specific point
- “Virtual category page” based on a custom field filter
- Group search results by category
- Simple way to style posts of a single category differently in the loop and in single
- Two Sections on Woocommerce Catergory Page [closed]
- Showing Categories for Page Edit – without plugin
- Display subcategories in dropdown
- Display category title and three latest post inside the category
- Using categories with pages
- Have posts that belong to multiple categories, exclude some categories from homepage
- Show multiple categories in query using redux framework variable
- Limit Loop to One Category
- Display post thumbnail for specific category outside the loop
- Filter Category Loop Dynamically
- the_category() doesn’t working in wp_query loop
- Conditional category query breaking?
- Category sticky latest
- Category name for all posts getting assigned to a single random post
- display specific category when website loads
- Include last post date in get_categories loop
- Show the number of the post
- How can I order all subcategories alphabetical independent of the parent categories?
- Custom Loop with certain number of one category
- How can I make a category function as a page?
- Displaying Category in sidebar post widget but not in the loop on home
- Querying posts from two different categories while looping inside another loop
- Trying to display all posts in a category
- Retrieving category pages from subcategory returns empty sets
- Loop doesn’t work
- Category For Pages In WordPress
- Display Taxonomies in loop with template args
- How to loop through a custom field for each post, & display?
- show category name before first posts in each category
- Getting page/category content to show up in my custom page template
- Using wp_list_pages to create 2 lists of pages and include and exclude some of them depending on their category
- Loop through posts of CatA and store value of CatB in separate array
- How to add an empty entry to masonry?
- Pages with posts filtered by category
- Category slug in in loop always the same?
- Pages, Categories, and working with someone else’s code
- how to get number of posts in a category on a specific date
- Show posted on date only for posts in a certain category
- Page redirecting to category (IE only)
- 2 loops in archive.php (one for each category)
- Using pagination with multiple loops causes it to break
- not empty categories don’t show in menu [closed]
- How to create a custom loop ordered by Categories on a Page Template?
- How can I show page per category in wordpress? (Yes, category by page!)
- Order Categories by Character Count