get_next_post set the category

Try this: $the_cat=”latest”; $term_args = array(‘orderby’ => ‘term_id’, ‘order’ => ‘ASC’, ‘fields’ => array(‘term_id’, ‘slug’)); $terms = wp_get_post_terms( $post->ID, ‘category’, $term_args ); foreach($terms as $term){ if($term->slug !== $the_cat){ $terms_to_exclude .= $term->term_id.’,’; } } $next_post = get_next_post($in_same_term = true, $excluded_terms = $terms_to_exclude, $taxonomy = ‘category’);

Same base for category and post

Change Category base to . (dot). Nobody knows this trick will work in the future, but there is no easy way to remove /category/ from the URL. So, it’s better to google for a plugin (here is one of them). Yoast’s SEO plugin also is able do the same. Set Permalink structure to /blog/%category%/%postname%/. Then: the_posts_pagination(); … Read more