If you’ll take a look at next_post_link
Codex page, you’ll see it’s usage:
<?php
next_post_link(
$format,
$link,
$in_same_term = false,
$excluded_terms="",
$taxonomy = 'category'
);
As you can see, third param is in_same_term
and it’s default value is false. If you set it to true, then the function will return next post from same category. (If you want the term from different taxonomy, you can change fifth param).
So answering your question… Yes, there is a way to achieve this. It can look like so:
<?php next_post_link( '%link »', '%title', true ); ?>
Related Posts:
- Single.php Category Post Count
- Get next post in same category not working WP 4.7.4
- Post in multiple categories do not include in previous / next post if one category in excluded
- adding custom fields to next and previous post link
- WordPress previous_post_link exclude posts with multiple categories
- Can I use get_adjacent_post for specific categories?
- Exclude Posts From Specific Category from Next and Previous post links
- Show category from “Next post” and “Previous post” [edited]
- Previous/next post links displaying wrong category than is desired
- get_adjacent_post – in same term or category not working
- Link to the next/prev posts in index loop in same category?
- Change next_post and previous_link to navigate throught parent categories only
- how to implement next/prev within category archive?
- Get the children of the parent category
- How do I get the category URL from get_the_category?
- wp_nav_menu not appearing for a couple pages
- Main menu not appearing on category pages
- How can I limit the length of the previous/next posts in my WordPress Theme?
- Problem excluding category from get_next_post
- specify meta_key / meta_value condition for prev_post_link and next_post_link
- Using previous_post_link and next_post_link to wrap around post sequence
- Create single.php for specific category by category id
- Is it possible to put next and previous category links?
- Post in Multiple Categories to stay in current category (permalink, next previous post link)
- How to get category id in single.php wordpress?
- next_post_link and previous_post_link in custom post type single page, in same non-custom category
- Previous/next link to post in category, NOT tag?
- connect last post with first post
- “next_posts_link” and “previous_posts_link” display me NOTHING
- Multiple menu items highlighted
- wp_nav_menu not highlighting the current category when viewing a single post
- in_category() works in single.php but not in page.php?
- Open subcategories in submenu on click in primary menu
- How to display only posts assigned to a particular, isolated, subcategory
- Is it possible to nest get_previous_post()?
- Checkboxes in the category list?
- Get Prevous/Next Post Specific Category Without Excludes
- Restoring default article pagination on archives – Removing custom limits
- Send to different single pages by category when multiple categories exist
- posts_nav_link(); picks up index.php instead of category.php as template
- Create menu / submenu from category subcategory and posts
- How to make the link to the category for a post go to corresponding page number in archive?
- How to get Next/previous_post_link to go through articles in top parent category
- How to display numbered pages in a category
- next_post_link / previous_post_link not working with WP_Query
- Ambrosite Next/Previous Post Link Plus or WP next_post_link to cycle through top level category
- Give Children Unique ID’s
- Problems with my conditionals in single.php by category
- Simple way to style posts of a single category differently in the loop and in single
- Multiple categories for one menu item?
- Show next post in same category but start from the latest
- How to get nav to show current_page_parent class when on regular post (not blog), differentiated by category
- Can’t get the previous and next posts permalink
- How can I check which archive has referred the single? [closed]
- Next/Previous links doesn’t work in the same category
- Displaying links to all posts of the same category on the post page
- How do I display a greyed out next_post_link when there is no next post
- Global navigation in multisite: problem with categories
- Include “Scheduled” (“Future”) Posts in WordPress Post Navigation ( previous_post_link, next_post_link ) for a Specific Custom Post Type
- How to get next post link of child custom post type from parent post and get next post link of parent post from the last child post?
- display specific category when website loads
- Ignore the Ad on Specific Categories
- custom wp_list_categories in single.php
- How to exclude posts by meta key value in the_post_navigation next prev links?
- Prev/Next Navigation on Single Post Disappeared for Custom Post Type
- How to add all subcategories as submenu in WordPress menu
- loop in single.php of the same category
- Change URL of previous posts and next posts link in WordPress
- Dynamic next and previous post links
- Next and previous links category infinite loop
- Display Some text in some specific category not all category
- omit categories from main navigation menu
- When category name and title are the same … WP will select archive.php instead of single.php
- Using template file for single post in sub-directory multisite
- Code to display category-specific single.php is overriding normal single.php, too
- Loop within category’s posts
- Next/Prev category post in same button
- Grouping parent categories into sections
- A simple question regarding tags and categories
- get_adjacent_post_link excluded_terms ignored
- Transfering static site to wordpress and retaining category by month paginations
- Display Referring Category on single post?
- Modify / Rewrite single template url structure
- How do I get a single page navigation depending on the previous page?
- Get all first images of posts in same category
- In category.php I need to get the next 10/previous 10 posts
- Previous / next posts using featured image thumbnail as links
- Is there a function to modify existing previous/next post link without modifying theme files?
- How we add new categories by wp_insert_post
- How to get category URL with the slug?
- need to add custom field in more products
- Display Posts Loop for each parent and for each Child
- How to automatically check multiple categories on new post
- Hide specific category from wp_list_categories
- ow to display the number of posts in a category
- How to remove category name for only one category?
- Unable to create pagination for Category.php
- Posts says they are uncategorized but they are not
- Paginations in Category Page Leads to Sample Pages
- If on Category Page add “active” class?