Excluding category from post navigation in WordPress?
Check the signature of the function: next_post_link( string $format=”%link »”, string $link = ‘%title’, bool $in_same_term = false, array|string $excluded_terms=””, string $taxonomy = ‘category’ ); Excluded terms should be the fourth argument. Your code is passing a “true-ish” argument to $in_same_term.