This is bizarre...
I have two posts that when I try to view them, they get a 301 and proceed to redirect to the next post in line. These posts are published. I don't have any plugins messing with redirections. I have tried disabling other plugins that could cause this issue. I have also checked the guid in the database and it's correct. The htaccess has the basic wp pretty permalink structure. For some reasons this 2 links have been marked as 301, and I can't see where this was done.
This is getting really weird...
So trying to troubleshoot I did the following:
1. Download the site to local dev. I thought if the problem is the whole link, then if I change it to a dev link, the problem will no longer exist. And that would rule out domain level 301 redirect.
Turns out that the problem still exisits under a different domain name.
2. Disabled all plugins I disabled all plugins. The problem persisted. Just in case, I deleted all plugins. No luck.
3. Search for hard coded links I searched for hard coded links in the whole theme. I also searched for any php redirects or js redirects. Nothing.
4. So I resintalled the WP core I wanted to make sure that had nothing to do with it. Nothing.
5. I deleted all revisions
6. Disabled ACF custom fields plugin I thought that maybe the redirect is hidden in some custom field. So disabled the plugin that displays them. The theme barely display correctly but the page redirects anyway.
I cannot switch themes, because the whole logic of displaying this page is done in the theme, and uses a lot of custom post types and fields.
So the next option, was to delete the page that the redirect was pointing to. So I for example I have Post 1 redirecting to Post 2. I deleted Post 2 (trashed it). The redirect still took me to the Post 2 page, but of course that now I got a 404 instead. Since Post 2 is in the trash.
So I decided to delete Post 2 from the trash, so that it would no longer be in the database. Once I deleted Post 2... tada! Post 1 was no longer redirecting. That solves the issues, but clearly I cannot delete Post 2 on the live site...
I am still clueless as to what's going on...
So I wanted to be 100% sure that the problem is not in the files but in the database. So I deleted pretty much everything, and only left what's need to make the pages in questions load without errors. That means that I deleted everything from functions.php, deleted all templates but the ones affected, delete styles, images... everything. Deleted almost everything from header.php.. leaving only the doctype and style inclusion (that's where the theme name is). And the redirect still happens. I even removed wp_head, and no luck. So now I know that the problem is in the database.