You should be able to just use the default get_next_post_link with $in_same_term set to true. Have you tried that?
Instead of your
<?php next_post_link( '<div class="nav-next">%link</div>', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'sixteen' ) . '</span>' ); ?>
try this
<?php next_post_link ( '%link →', '%title', true, '', 'category' ); ?>
Related Posts:
- How to show next Post Thumbnail image in WordPress using current post id
- The the_post_thumbnail without srcset?
- after_setup_theme always runs
- Using classes instead of global functions in functions.php
- WordPress API Menu/Submenu Order
- How to move page template files like page-{slug}.php to a sub-directory?
- What WP folder can I use to write files to?
- Are the WordPress Core CSS styles really all nessesary?
- Why I can’t add a CSS style in this WordPress theme?
- Setting multiple default background images?
- How to make a theme with more than one CSS file?
- register_sidebar ignores ‘id’ and ‘class’
- Display a different theme for not logged-in users
- Best practice (forward compatibility) for theme options
- Add colors to existing color palette without replacing it
- Single Page WordPress Theme – Using page templates
- Can I upload WordPress-react theme in Wp theme repository
- Returning Variables back into a template
- new theme permissions don’t allow me to edit
- Which theme foundry has clean coded themes, where code is poetry [closed]
- What page should I use for a contact form?
- Retrieve data using wpdb to use for customizer controls
- How can a Theme Contain no Header File or Footer File?
- Cannot get full thumbnail size using the_post_thumbnail
- Version control for both Vagrant config and themes being developed [closed]
- Is there a way to activate different theme for specified users? [closed]
- Some translations do not work in my template class
- WordPress not registering Theme Customization Section
- How to remove a file included in parent theme with locate_template() via child theme?
- qTranslate with my own theme and settings
- Stylesheet not linking
- How to control layout of posts on page?
- Override template file i subfolders
- Theme Development for WordPress Multisite Installation
- Include Parent functions.php in Child Theme functions.php
- create category on theme setup
- Change locale by detecting viewer’s browser language setting and let them choose prefered language after
- Why is it needed to enqueue parent stylesheet in child theme?
- Customizer: save setting/control content to post/page
- WordPress Unite Theme: Footer isn’t sticking [closed]
- WordPress get_template_part() function not working
- Where am I doing wrong in my theme menu?
- How can my theme allow users to take advantage of advanced html tags in posts
- How to enqueue javascript for WP Customize options sidebar?
- WordPress 500 Internal server error when activating custom theme [closed]
- Customize how a WordPress theme looks like in the Theme Selector
- how to get the post attachement image in full size?
- Best way to develop a new theme on a live site, with new content? [closed]
- How do I make the most minimal vanilla theme possible with nothing but raw content?
- Can I Set Up Session in WordPress Custom Page
- Template for landing pages
- Set a featured image as a replacement to the header image
- Custom theme: How to call archive-post.php for viewing blog posts
- underscores use of the article element on the page template
- Plugin does not work in custom theme
- html5-reset theme does not show the image [closed]
- Theme Customizer not displaying saved values in wp_head (CSS)
- Adding a gallery to my first theme
- How can I hard code my sidebar?
- Thesis -style Navigation
- How can I wrap all blog posts image with
- Issue when posting updates/changes to wordress
- StoreFront WordPress theme: How can i create a new Home page with Custom design same as template [closed]
- A post with a clear:both in its css destroy the theme design, and the sidebar is moved to the bottom
- Create theme for mobile phones and tablets only?
- Never actually adding the action? Or do I have to call the action?
- How to hide custom sidebar on mobile
- Theme Checker Text Domain
- How to copy page/post from one theme to another?
- Not sure how to debug this npm install error. This is a wordpress theme that comes with a built-in gulp/webpack task automation [closed]
- How to change listing type permlink?
- Calling a WP Plugin Function’s Variable in Theme Template [duplicate]
- Why front-page.php doesn’t show content of file instead shows loop
- Local variable name in setup_postdata()
- Creating a Single Page Theme correctly
- How can I not disable my theme when I want to upload a new version of it?
- Are paginated comments required for publishing Themes?
- Child theme menu not appearing in Twenty Seventeen
- How can I fix my theme header for my CSS stylesheet?
- How do I remove header/page-title image in farvis theme? [closed]
- Is hand coding required at all?
- Avoiding do_shortcode() loops
- Creating a Sub Category Template
- How to link post image to post link?
- Correct was to customise theme using get_theme_mod in scripts
- Custom theme vs theme customization?
- how can I re-utilize and class on a child theme
- WordPress Theme Developments – Start from another theme
- Can you create a custom page with content in the center already defined?
- How to migrate the menu from the site on my own theme in WordPress?
- How Does One Create a Global Variable Repository
- RSS feed url showing page not found. How to solve it?
- How to convert that page to a wordpress template? [closed]
- Toolbox theme using printif statement – help needed understanding code block
- php file child theme directory not overriding parent theme php file [duplicate]
- Any Cool WordPress Theme Editor? [closed]
- How to Create a Multi Purpose Theme?
- Custom Single Page Portfolio Theme [closed]
- Is there any open source WordPress Themes?
- How do I send out an update for my custom wordpress theme?