I am using the Post Object to highlight a single blog post but I would like to exclude that post from showing up in the main_query.
How do I exclude that post id from showing up in the default loop?
I found some stuff like $query->set( ‘post__not_in’, [3356]); but I want it to be dynamic.
Thanks in advance for any feedback.
That depends on where your post object is saved (post, options, somewhere else?)
Currently the Post Object field (Default Posts) is selected on the Posts Page (index.php) but that could easily but transitions to Options as the Posts Page does not really serve much purpose except to serve as a listing for posts.
You need to get the field from where it is located. If it’s on a post then you need to supply the post id.
$query->set('post__not_in, get_field('post_object', $post_id, false));