Use get_adjacent_post to first see if there’s actually a next post:
if (get_adjacent_post (false, '', false)) {
next_post_link ('%link', 'Next Project >', true, '', 'projectcategory');
} else {
// manually create link to first post here
}
This site shows one way of actually getting the first post’s link, such as with a WP_Query call and then calling get_permalink. The exact code depends on the types of post you are showing.
Related Posts:
- Loop – how to get previous/next post for first/last post?
- How to display Yoast SEO meta description in archive template for each post instead of the_excerpt()? [closed]
- Get ID of a page containing secondary loop in content
- How to add “time” data this?
- How to hook into container
- Output meta into arrays
- value of metadata is null wrong use of if statement
- Sending mail not working correctly
- using update_user_meta to rank users
- get_post_meta printing empty fields, but it shouldn’t be
- Check value of post meta within IF statement
- Best way to check if a post with specific meta exists
- WP update_post_meta link loop
- Humanmade | Custom meta box class: How to display a repeatable meta box group?
- Display articles related to a custom field on a page
- How to fix pagination for custom loops?
- Why should I put if(have_posts()), is while(have_posts()) not enough?
- AJAX with loop filtering categories
- Remove the Homepage Query
- A search for ‘0’ returns results
- Custom Loop and Infinite Scroll
- Loop that displays PARENT PAGE & CHILD PAGE & outputs GRANDCHILD PAGE title and content
- wp-admin redirecting to https, denying login
- Add Incrementing ID to each paragraph in the_content
- Grossly inefficient wordpress loops!
- Multiple posts with one loop iteration
- Query date in wordpress loop
- Custom Loop, Match Category with Page
- Display page of custom posts?
- get_the_content not working in loop?
- Get link of inserted media file of post within loop
- If No Search Results, Show Posts from Alternate Search Query
- Output shows a page instead of a list of blog postings
- multiple loops with pagination on the same page
- Custom search form to display users only
- Multiple loops on the same page removing post tags
- Pages inside a page (with thumbnails)
- How to make post content from each post display within the same div
- How to order posts by meta_value created inside loop?
- How to get_posts where ‘menu_order’ is more than 0/zero?
- Meta Key Value in current-user-only loop
- woocommerce stored variable
- Get search.php results in header.php?
- Recent posts on a static home page
- I write simple wordpress loop for taxonomy.php file but don’t show result
- A smarter way to display multiple loops inside a page template
- How to print out menu names in the foreach loop?
- How do I style the first two posts of a loop
- Do I need to use The Loop on pages?
- Pagination – works on local but not live dev!
- Does WordPress Loop have a function like Shopify’s cycle?
- How to show more random posts if Tag has less than 3 posts
- How to display pending posts on the homepage only for editors
- Add leading zero to current post display [closed]
- Distribute Gallery Images Every nth in Loop
- WordPress Image Slider Looping Title Not Working
- Change all author links in Blog roll
- Is there any good reason for two CSS files to @import each other?
- Adding div after every two post on main loop! Why will first post not get counted?
- Second Loop Showing Only One Post on Single Post Page
- How to add post meta in while loop?
- Random post link generator messes up the loop
- how can i order the category by date
- Change position of entry title
- excerpt not showing up
- Pagination for two loops
- Announces with different formatting dependently on a number
- Override orderby to create list of users by custom meta_value
- Thumbnail Image Rounded Corners w CSS (or any other good method)
- Several loops in sidebar issues
- List page is showing 404
- Duplicated tag in loop
- Loop only shows first two posts
- Why is my archive page looping through all but one post?
- Loop two different category WP_Query
- Use ACF Category Image for all Taxonomy Archive Views
- Loop with custom posts, to include information from different custom post type
- My WordPress installation doesn’t load correct template
- Transient not working for external data
- Is it possible to sort the post based on a custom field?
- adding tax_query to $query_string
- Remove posts_orderby filter then add it back in
- the_title() Returns the page title instead of the post
- Category foreach Paging
- How do I aproach this?(for sale, for lease, sold->move something from a category to another)
- How to fix pagination for custom loops?
- Conditional Check in The Loop’s Parameters
- How does the JSON API work to parse incoming JSON and fetch a post based on an ID?
- How to add excerpt in loop in Twenty Eleven theme?
- show posts from one category with comments only
- How to implement template file and the loop
- Show only posts from todays date [duplicate]
- I need to update the post query? [closed]
- Wrap every 2 divs in row – for each loop [closed]
- Multiple loop with pagination in same page
- Why did my most recent article fall behind an older one on my site?
- Query Loop Block: possible to restrict just child pages?
- Using Query Loop Block to list all posts under each category
- Different date time in results of search
- Users as team members through a loop in elementor