If you have a look at what next_post_link
you’ll see that it takes a parameter $link
as the second argument:
next_post_link( $format, $link, $in_same_term = false, $excluded_terms="", $taxonomy = 'category' );
Your parameter for this currently doesn’t include the post thumbnail:
_x( '%title <span class="meta-nav">→</span>', 'Next post link', 'nicosite' )
So we need to add it like this:
$nextPost = get_next_post(true); // You are aware that this only checks for next posts in the same term, right?
if(!empty($nextPost) ){ //This is to check if there is a next post
$nextthumbnail = get_the_post_thumbnail($nextPost->ID, array(300,150) );
}else{
$nextthumbnail="";
}
next_post_link( '<div class="nav-next">%link</div>', $nextthumbnail . _x( '%title <span class="meta-nav">→</span>', 'Next post link', nicosite' ) );
Related Posts:
- previous / next post with thumbnail
- Is it possible to nest get_previous_post()?
- Next Prev Post link rendering current post thumbnail
- Show prev and next post links for parent post of current image in attachment page?
- Showing Thumbnail from Previous and Next Posts
- Featured Image Link to next post?
- How do I set a featured image (thumbnail) by image URL when using wp_insert_post()?
- Can the Next/Prev Post links be ordered by menu order or by a meta key?
- How do I get image url only on the_post_thumbnail
- How to get image title/alt attribute?
- How to Fix HTTP Error When Uploading Images?
- Add class name to post thumbnail
- How to disable WordPress from creating thumbnails?
- How to retrieve image from URL and set as featured image/post thumbnail
- How to set featured image to custom post from outside programmatically
- How do you remove hard coded thumbnail image dimensions?
- How do you get the post thumbnail size?
- Setting a post’s featured image from an embedded YouTube video
- How to get featured image’s width and use elsewhere in template?
- set_post_thumbnail_size vs add_image_size
- Minimum Dimensions Requirement for Featured Image?
- Generate Thumbnails only for Featured Images
- How to get all featured image sizes and their URLs?
- How to Dynamically Resize WordPress Image On-The-Fly (custom field/theme option)
- is it possible to get next_post_link
- How to add post featured image to RSS item tag?
- How do I regenerate thumbnails?
- Display thumbnail only if requested size exists
- Delete original image – keep thumbnail?
- the_post_thumbnail responsive srcset not populating with custom image size
- Set custom name for generated thumbnails
- Post thumbnail alt title
- Get Featured Image via direct sql query
- Get featured image on Blog Index
- the_post_thumbnail hard cropping not working no matter what
- Get Previous & Next posts by Post ID
- Can I refresh the thumbnails programmatically?
- Filter next_post_link() and previous_post_link() by meta_key?
- How to add multiple image sizes of the same size with add_image_size
- New image size version only for the Featured Image file
- wp_get_attachment_image_src always returns full-sized image
- Get featured image URL by page id
- change set_post_thumbnail_size according to post type admin page
- Add Title Attribute to WordPress Image the_post_thumbnail
- Can’t extract and set SVG dimensions
- Set Featured Image Front Frontend Form
- How can I add title attributes to next and previous post link functions?
- Getting Thumbnail Path rather than Image Tag
- Display Category Thumbnail and links in Woo commerce
- the_post_thumbnail with lazyload JQ plugin
- Replacing Gutenberg Featured Image control?
- Display Post Thumbnail Without Being Featured Image
- Featured Image of Video from oembed
- oEmbed, thumbnails and wordpress
- wp_get_attachment_image_src() and custom sizes
- How to get next and previous post links, alphabetically by title, across post types, in a shortcode
- Prevent WordPress from cropping GIF files
- media_sideload_image generates blank?
- get_adjacent_post alternative on a very large db
- Post thumbnail outside the loop
- What’s the difference between post thumbnails and featured images (if any)?
- Getting custom-sized featured image’s URL?
- What is your take: TimThumb vs. WordPress Thumbnails? The great debate [closed]
- How to crop thumbnail height to auto with set width
- Retrieve 1st image in post and set it as featured image, when post is saved/updated
- Use thumbnail image using url of that image
- Retrieve featured image as object
- How do I add the featured image to the_content after the first paragraph?
- Showing a placeholder/default img, if no featured image is set
- Re-order media links?
- Multiple featured image thumbnails for post types (Multiple Post Thumbnails plugin)
- How can I get next/ previous post links to order by a filter (by the last word of the title)?
- the_post_thumbnail scaling not hard cropping
- Skip posts without a thumbnail in loop
- next and previous post link ordered alphabetically
- wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); Getting thumb from wrong loop
- Set featured image for multiple posts
- Image uploader with “Set Featured Image” link on front end
- Thumbnail (featured image) of next and previous post is not being properly displayed!
- adding an id to the_post_thumbnail
- Featured image size in ADMIN panel?
- Featured image with the same height thumbs returns wrong thumb
- How can I display my featured image correctly inside my single posts?
- How to change the naming of the resized image files
- Featured image upload finished hook
- How to get featured post title & image using JSON API?
- Generate thumbnail for images with the same size as thumbnails
- Set post thumbnail as background
- Display thumbnail only on the very first post in the loop?
- How to show featured image CAPTION only if it exist
- How can I limit the length of the previous/next posts in my WordPress Theme?
- Set post-thumbnail (with php)?
- get_thumbnail_id returns full size image
- Implementing Zurb’s Interchange Into WordPress
- can the_excerpt function also get images?
- How to use next_post_link and previous_post_link on single posts in search results
- Next/Previous Posts Links: Alphabetically and from Same Category
- How to get_posts having post thumbnail?
- Add Image Dimensions to Media Library Tab on Media Upoader
- Change Output for Images in Content