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
- Can wp_query return posts meta in a single request?
- compare meta_query in get_posts arguments
- Function in array as arguments for WP_Query
- Query Posts in a Predefined Order
- What kind of object type is WP_Query?
- meta_query where value is equal to given value
- Getting an array out of WPQuery
- How do I search an array stored in a custom-field using WP_Query?
- Order by meta_value_num DESC and meta_value ASC on WP 4.0
- How to use filter hook posts_join for querying taxonomy terms in posts_where?
- WordPress altering my custom query, How to fix it?
- Placing a div or img in between a post array using WP Query [closed]
- How to query ‘posts_per_page’ to display a different blog posts index template?
- Order by meta_key in custom post type doesn’t affect the query
- WP query exclude post within the last month / only show over 1 month old
- WordPress query for most recent posts from multiple categories
- Filtering posts by custom field value not working
- Too many posts cause slow load when paginating
- Order by value in serialized custom field
- Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]
- Order Posts by meta value AND published date
- Query post with meta_query where date is not in future
- wp_query add arguments using array_push if variable met
- Group WP_Query by meta_key date
- WP_Query last five posts, simply ordered by meta_value
- Order query by meta_value with multiple custom fields
- How To Fix WP Query Returns Results But Shouldn’t?
- WP_Query “OR”: Find posts by ID, Name or Post Title?
- WP_Query condition affects posts_per_page count
- Orderby is working with one query but not with other
- Weird orderby => post__in issue
- Slow page loads due to WordPress Core Query
- Adding multiple meta_key fields as orderby options to a WP Query via a function
- meta_value_num not ordering all items
- Redirect to another page using contact form 7? [closed]
- Advanced WP Query and/or
- wp_query get data from advanced custom field in wordpress
- How to compare a date in custom field with today’s date in custom WP_Query?
- How to create custom query by keyword in post title?
- WP ForLoop to compare meta information of posts to determine what post to display
- get_posts custom field
- wp_query posts with custom fields number smaller 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
- Querying a large number of posts including their custom fields data
- Related Posts Excluding Certain Categories
- 2 queries with counters
- How to avoid filling up an array each time I run a WP_query?
- Multiple Query_Posts
- Query multiple post types, but different order for each
- Order by the first array within a meta_query
- Query ACF relationship field – Comparator IN – Value array
- How to _GET multiple value checkbox WP_Query in Custom Toxonomy / Custom Fields
- Combine relationship posts with existing wp_query
- Duplice post with standard WP loop – fixed by using query_posts() instead
- Comparing Meta Field date in WPQuery using Meta_Query?
- Custom query for custom post type not getting correct post ID
- WP_Query, ACF field and array
- using custom meta user data to run queries in WordPress
- Merge two queries and remove duplicate
- Meta key in wp_query bug?
- Seach and categories not working when ignoring sticky posts in main loop
- posts_per_page increment additional post
- Calling body_class and wp_nav_menu for a different post
- Wrap group of wp query posts to parent div by date/year
- Using custom field as ‘orderby’ value causing post grouping by publish date
- how to query for meta_value have array
- Sorting Posts with meta value not working
- How to query post ids liked by the Author
- Dynamically name array in WordPress loop – add/get values
- Creating Custom Query
- Help in query for list links
- WordPress pagination returns the same posts
- Get posts by meta value except one post [closed]
- Display ACF object field data using Elementor Custom Query
- WP Query – Show custom posts only if user contain some user meta
- Show number of posts AND number on current page (cannot make it work)
- How to include custom fields in wordpress search
- Extend search query to search meta keys values based on search string
- new WP_Query with order args – no more distinction between categories