I’m writing a plugin but I have a problem. When WordPress is displaying posts & pages on the site, I want it to skip that post/page when the custom field show_post equals 0 (this is a simplified example). How do I do this?
Please remember that this is for a plugin, not a theme, so I can’t just edit the theme to skip those posts/pages.
Assuming you want the plugin to work for all themes and all queries.
You can use something like
Update: added
if($posts)condition to check if the query returns ID’s or not.