If you’re using WP_Query
to do your loop it should be as simple as getting all the post IDs and then setting them as negative in the p
parameter.
For example:
$unwanted_posts = array(); // you must generate this
$unwanted_posts_str="-".implode( ',-', $unwanted_posts );
$args = array(
'p' => $unwanted_posts_str
);
You can also set this on an existing query using the set()
method.
Related Posts:
- Loop through two different sets of custom fields
- Ordering posts by metadata
- get_posts() not working when accessing with a custom user role
- How can I add an image upload field directly to a custom write panel?
- How do I improve this admin query snippet to avoid generating duplicate results on non-meta searches?
- How to return only certain fields using get_posts()
- How to validate custom fields in custom post type?
- How to add tab which is visible only in admin side of product in woocommerce? [closed]
- get_template_part from plugin
- How to control output of custom post type without modifying theme?
- Creating custom field with drop down on new post page
- Why Does get_posts() Return an Empty Set?
- Unit testing to simulate the loop
- Save metabox with multiple checkbox array
- get_posts / WP_Query Memory size of 134217728 bytes exhausted
- Retrieving custom fields with $wpdb->get_results
- How to create Image gallery Metabox in wordpress [closed]
- Utilize TinyMCE hyperlink chooser outside of TinyMCE
- anything like add_meta_box for categories?
- Calling Specific Pages with wp query Part II
- How to Display Custom Post Type’s Gallery (images ) in Through WP_Query
- template_redirect for single posts w/ custom fields
- Paging on a future post loop?
- Support auto-save and revisions for custom fields
- Best choice of options/settings framework for plugin/theme development
- Finding posts containing matching array elements in a meta field usign WP_Query
- get_the_excerpt() not working in plugin loop
- using new WP_Query in save_post function alters $post
- Adding set of custom fields to WordPress Post in Dashboard
- Slow WP_query due to nested wp_query. Need Suggestions
- get_posts that match a user-specified value on a page
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- Custom Taxonomy to dropdown box on adminside wordpress
- Create & Save multiple Meta-boxes
- Saving value of a selection option in comment form as comment meta
- get post attachment using ajax
- Strange issue saving custom field data for a WooCommerce order
- Woocommerce – Convert Delivery method into a custom field
- Elementor custom Query with ACF fields to show matching woocommerce products custom fields
- How to get Metabox custom field to show checked if value is updated using post meta query?
- How do I update a field of a meta box?
- Input value from metabox is not found in $_POST after post save
- Run Shortcode of post’s custom field in functions.php / Plugin
- Meta Query returns wrong number of posts
- How to get post content by get_posts function?
- Custom code for WordPress dynamic menu
- Why does my widget break other widgets?
- What’s wrong with this post__not_in argument?
- Checked() function on a multidimensional array
- How to get the post excerpt using post object?
- What is the best way to store a few fields?
- Remove entire [$key] from array stored in custom field using Ajax – unset($array[$key]); not working
- How can I add a simple custom field to my plugin?
- Ajax is not working in a loop
- Add function after the_content
- How to save post meta as an array in Gutenberg?
- Issues Updating Post Meta with AJAX (Seems simple but cannot figure it out)
- per blog metadata for plugin
- How to format custom fields when editing an attachment?
- Get audio metadata on file upload
- Loop through incrementing custom fields
- Get Posts by IDs (optionally)
- Any way to update_post_meta with html content? It gets stripped and becomes empty
- rewrite_rules problem
- how to add custom fields into new & update post page?
- Customise Grouped Product display in Woocommerce with custom column
- Count products with custom metadata field in an order
- How do I add filter with woocommerce categories?
- WP_Query not ordering correctly
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- Adding customs fields on each product on the cart
- Foreach Loop Of Post Types With Nested If Else If Not Completing Process
- Don’t print customizer styles when no setting has been used
- add_meta_box does not display meta box in Admin
- How to include files in the loop via ajax
- Sort loop by custom field from different post type
- How and when would I implement some code which would take data from one part of the Db and put it in another?
- Displaying Custom Post Meta
- How to exclude posts with empty and non-existent relational custom field with meta_query?
- Error in WP Query. If variable is empty it is displaying previous post value
- Custom query not working in plugin admin page
- Best Way to Grab Post ID from Plugin
- WordPress Meta Query: Relation is not working correctly
- How can i call from custom fields to the category editor?
- loop through custom post-type with two meta_keys
- How do I query posts and have their related taxonomies returned in the results?
- Loop output for custom plugin [solution found]
- I want to display the content of a text field only if it has been entered
- Outputting custom field query from a plugin to the website header
- Create Unique and Customized User ID for Website Members in WordPress
- What is the meta_query key name for the woo product average rating? [closed]
- Can I log the searches that are returning 404 in the DB?
- filter on get_posts efficiently
- A better way of getting draft posts that has a particular post meta using get_posts function
- Create a clickable name in WP_List_Table for Plugin Admin
- Plugin development without Theme adjustments?
- Is it possible to sort the post based on a custom field?
- Can’t we use strings defined as PHP constants if we want to translate them in a plugin?
- Ajax +wordpress onClick link redirect to new page and create html content
- WC REST API Error Handling