global $wpdb;
$excludeposts = “SELECT * FROM $wpdb->posts
WHERE $wpdb->posts.post_status=”publish”
AND meta_key NOT LIKE %aa_%
ORDER BY post_date DESC
“;
$main_query = new WP_Query( array(
‘post__not_in’ => $excludeposts,
‘paged’ => $paged
)
);
while ($main_query->have_posts()) :
$main_query->the_post();
//Stuff...
endwhile;
//hope this helps
Related Posts:
- How add a custom posttype name using ACF field to a query post array
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- How can I pick a single post from the latest 3?
- Fetch Record based on meta key dates
- How to list custom fields as headers and list all pages sharing that custom field under it?
- how to make members list directory through wordpress post custom meta key.
- Include current post into loop
- Order post type by sum of two custom fields
- Conditional operator OR not working with custom fields
- Posts query according to meta box date
- How can I comment comma-separated array values?
- How do I add a relation parameter to my filter query?
- Query using string from custom field as array value
- How do i create a custom post query when the meta value is an array?
- Retrieve all custom field values of a specific custom field metakey as an array, inside WP_Query
- Trouble with serialized metadata
- Problem with my loops
- Custom WP_query and integrating into theme file
- query_posts with sorting on a custom datestamp
- query post based on comparison
- WP ForLoop to compare meta information of posts to determine what post to display
- WP_QUERY with group by with custom fields
- How to order posts on each different category?
- Posts Query | Query to only show sub categories
- Intiger meta value with ‘>=’ returns posts with lower value
- Display posts with specific value first in query
- get_posts custom field
- Get every post with value in meta key
- Using get_posts to get posts based on a checkbox value with Advanced Custom Fields
- wp_query posts with custom fields number smaller than
- create metabox to activate slider
- Query posts using less than
- Retrieve select tag custom values from array and display them in current page with wp_query?
- How to use a dropdown to filter posts by custom field
- Order WP_Query results by meta key value in custom query
- construct complex queries with WP User Query
- Excluding posts with certain value of meta_key keeping posts without that meta_key
- Query only displays one page_id
- Get a list of ACF Repeater-Fields as array
- Order a WP_Query by meta value where the value is an array
- WP_Query with page_ids in arguments without a result
- Querying a large number of posts including their custom fields data
- Related Posts Excluding Certain Categories
- query_posts with meta_value
- Display post meta conditionally based on it’s value
- Creating attachments archive in tags and categories
- How to use ‘WP_Query’ or ‘query_posts’ to display content in a descending order
- Get next/prev image/attachment in time with date query
- How to show list of posts with custom field value (a date) that are coming soon
- add_query_arg to compare and display events from a certain date
- 2 queries with counters
- Multiple meta query from array
- Show single posts date, in a page of posts
- Comparing 2 Decimal Numbers from custom fields and displaying posts
- Sorting posts by Multiple custom fields in defined order
- Max Posts and Memory Limit
- Category based on post id
- How to get specific string in explode array?
- How to avoid filling up an array each time I run a WP_query?
- specific post is not excluded from the loop
- Why doesn’t my WP Meta Query return any results?
- Multiple Query_Posts
- Remove from array in WP_Query loop
- Paginate pages with dynamic query
- filter posts by meta key with pagination
- Trouble Making WP_Query paged
- Performance concerns: index.php vs taxonomy-$taxonomy.php
- Determine if ID is page or post and query the ID
- How to query for a page, get data, then query for child pages of that page
- Custom template for password protected page
- WP_Query Class custom field parameters
- meta_query returning excluded result
- Add AJAX “Load more” on custom query block
- Posts limit on homepage (genesis framework)
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Optimising WP_Query with ACF Fields
- Elementor posts custom query based on tag [closed]
- meta_query weird behaviour, static int will work, but not user data
- Query post and sort by custom value calculated with custom field on cpt
- WP query_posts group by meta field related
- Query multiple post types, but different order for each
- Order by the first array within a meta_query
- Woocommerce Shortcode which displays a table with product data
- Query ACF relationship field – Comparator IN – Value array
- Filter products on category AND tag
- ACF: How to query for a given value count of an array like field? (e.g.: How many rows has a `flexible_content` field?)
- Query post ordered by meta value that show first post that contained a tag
- How to _GET multiple value checkbox WP_Query in Custom Toxonomy / Custom Fields
- Facing problem with tax_query results
- How to add a “base” filter for all posts visible to visitors on the site?
- Sort custom post by custom field if none order by latest release
- Combine relationship posts with existing wp_query
- display ACF repater field in archive page
- Counting instances of words in the results of a post query
- query hook parse_tax_query function takes no effect
- Query posts by post type, author and post meta
- sanitize_post() is not sanitizing Post Object
- Duplice post with standard WP loop – fixed by using query_posts() instead
- How to use the Term Object from a custom select field in a query
- ElasticPress is (aparently) messing with my search filters