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
- Retrieve each widget separately from a sidebar
- how to upload image using wp_handle_upload
- Avoiding using a loop to access a single post
- Adding ‘current_post_item’ class to current post in the loop
- Get next/previous cousin page
- Where should I use post_class()?
- Landing Page – Redirect Loop?
- How to make multiple Column in archive Page?
- Sort Popular Posts by Views for the Last Week
- get_the_foo() in the loop – does it perform another query?
- Exclude filter on front page
- Is it possible to display previous post revision?
- Check if date of post is yesterday
- Exclude first 2 posts with meta_key from loop
- Fix inefficient loop breaks post.php on form submit
- Adding shortcode closing tag after a loop
- Get Pagination (WP-PageNavi) not to work
- Filtering The Loop For Single Page and Blog Page
- the_content() seems to block my ACF-code
- Pulling current post/page data into header.php
- Removing the_content() from the page
- Loop and Page template : my WP_query don’t take args
- Infinite blog loop
- One custom loop with condition to check child posts
- Loop get_theme_mod
- Move sticky posts down in main loop
- Why only one post (and no pagination) on this variation of the loop?
- Displaying terms based on loop posts?
- Custom post type appearing within the previous one on archive.php
- How do I go about looping through a advanced custom field on a particular page inside of another page
- Template structure
- The Loop – mixed ASC and DESC order
- Filter the_posts doesn’t work on search page
- Pagination not working in category listing [duplicate]
- How to get the excerpt for is_home() outside of the loop isn’t working
- Make loop alphabetical
- How to check if a product is purchased within the last 365 days before displaying something
- Category links including all posts
- Custom loop ordering not working
- First archive page with a few posts
- Hiding a row in the loop if empty
- Loop through ACF taxonomies and output associated posts
- How to get user ID’s from multiple usernames?
- Query posts only with actual text content (not including shortcode or images)
- The loop starting at a certain ID
- How can this multiple loop have pagination as described?
- Default featured image set as background image [closed]
- Breaking up the results of a loop
- How do i create a list-posts-page?
- Exclude posts based on an array
- Is file_exists() compatible with timthumb.php? [closed]
- List ALL posts by author on author archive
- Using is_page_template inside loop
- Set depth of pages to fetch
- Trying to get all links in my posts
- Creating a User-Adjustable chart in WordPress
- Archive: Lists itself
- Please tell how to stop the category from showing up on posts
- How to show the last article in a different way in my blog?
- Can’t limit posts_per_page in loop
- Reorder posts in a loop: have the posts by one particular author below the others
- how to get author comment inside the loop?
- How to create loop in custom page, and get id from url into this loop?
- How to fix pagination for custom loops?
- Check to see if a field is within an array in twig
- Archive sorted by month – separate
- Display single post inside accordion based on form submission results
- One page loop issue with posts
- Can’t print out returned value
- Building theme so user can change header image [closed]
- Get query result before posts are displayed?
- WordPress Group By Problem
- Home page loop with pagination problem
- why get_post_meta is returning 0?
- WooCommerce custom loop pagination on front page
- get_page() unlike Loop returns the post content without html tags. How can I fix this?
- Problem with ms-thumb-frame-selected class in Master Slider
- I want the first post on my home page to be lengthier than the rest (example included)
- Loop with Custom Post Type Taxonomies and Interstitial Code
- Question about custom plugin
- Display all posts in a page code for template
- How can you make it so the comment box shows on some pages or posts but not all?
- Add a “Next Post” & “Previous Post” styled button manually to a post
- wp_mail sending only once inside foreach loop
- How to use orderby on meta_value when using Pods custom database table storage