Trouble preventing duplicate posts between 2 loops on homepage

As usual with multiple loops, one of which is main loop, the issue is messy.

What it looks like is happening:

  1. Secondary loop runs and deals with some posts.
  2. Main loop runs and deals with some posts.

What is actually happening:

  1. WordPress core is loaded.
  2. Posts are queried for main loop.
  3. Template file is decided on and loaded.
  4. Secondary loop runs and deals with some posts.
  5. Main loop runs and outputs those posts queried way above in the process.

To cleanly accomplish what you want would take:

  • completely moving that featured logic out of template
  • using it to override what is queried for main loop on pre_get_posts hook (massive topic by itself, search around the site)
  • storing that info and using it way later to run custom loop in template

It’s not overly complicated, but very menial and prone to errors (as in I wouldn’t even try to modify this going by snippets without hands on access and testing on actual theme and site).