Solved
So i ended upp with a simple SQL-query:
$sql="SELECT post_id FROM kwido_postmeta WHERE meta_value REGEXP \""'. $area['area'] .'";a:[[:digit:]]+:{[^}]*"'. $mainpost->ID .'"\'';
$results = $wpdb->get_results( $sql, ARRAY_A );
That looks after the current post_id and area with a regex, then if found get the post_id..
$post_ids = array();
foreach ( $results as $result ) {
$post_ids[] = $result['post_id'];
}
With the post_id:s i make the query with post__in
parameter which accept arrays.
$args = array(
'post_type' => $type_areas[$area['area']],
'posts_per_page' => '-1',
'post__not_in' => $post_ids
);
$query = new WP_Query( $args );
Related Posts:
- order by numeric value for meta value
- numberposts? showposts? posts_per_page?
- $GLOBALS[‘wp_the_query’] vs global $wp_query
- Some doubts about how the main query and the custom query works in this custom theme?
- How to query posts based on lat-lng coordinate as post meta?
- Set Alias for meta_query arguments in get_posts()
- How to query only for products with status “in stock” in WooCommerce? [closed]
- WP_Query displaying ALL posts
- Does WordPress sanitize arguments to WP_Query?
- WP_Query meta_query where meta value ends in space
- Highlighting Sub topic in a post?
- How to combine tax_query and date_query in WordPress
- How to get any tag ID
- WP_Query with many meta_query arguments taking a long time to load
- Slow speed and high CPU usage for my code. How to improve it?
- Multiple queries on Home Page – page load/site speed issue
- wp_query display posts from same category of the post
- Targeting specific pages in the loop
- WordPress custom archive page
- query attachments of parent page if attachments of current page are smaller than …
- Order posts by meta value and Date
- Include Sticky Posts in Page Post Count for custom query
- Query sticky posts with thumbnails
- Show all parents and children in custom post type in right order
- Why is this coming back as null? Thats wrong. There is one post
- Retrieve featured image (thumbnail) url from multiple posts with one query
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- Can you order posts from wp_query by two custom meta fields?
- Retreaving all images attached to current post
- wp_query() get_col error
- Pagination working everywhere but the index page
- How to select posts from one category but exclude posts in another category?
- How do I search inside specific taxonomies in WordPress
- Order a query result by a numeric meta key even if it does not exist, but put the posts with meta key first
- How can you get first post, last post and post count in a category?
- What’s the purpose / logic of split_the_query in WP_Query->get_posts
- WP_query posts closest to todays date
- if statement in wp_query arguments
- Need wp_query to return all children and grandchildren
- How to use offset in WP_Query
- difference between like ‘%%%var%%’ and ‘%var%’
- WP Query Category Atribute Not Working
- How to build a WP_Query using mulitple tags and using AND or OR operator between them
- new WP_Query to get max price meta value not working
- wp_query should show stickies first
- How to orderby multiple meta fields if some fields are empty
- WordPress custom post type with meta – how to retrieve with wp_query
- wordpress search word, “hello world” ===> ‘hello+world’ ===> ‘hello’, ‘world’
- Order by meta value (numeric value lower to higher)
- Wp_query calculate points
- Wp query show post by author name or post title or post content
- wordpress ajax relationship query
- get data match with extra field value using wp_query for custom post
- Admin Page Post Id wp_reset_postdata not working
- Multiple queries and performance – wp_query
- WP_Query for a taxonomy with different taxonomy types
- Append URL query to next post link in custom query
- Display single most recent post in category on every page of category archive
- Executing query_posts after wp_insert_post
- Redirect Search to Form When No Product Results Are Found
- Show menus to one admin username
- inserting content of 1 Post to in another with a template hierarchy
- get_posts custom field
- wp_query posts with custom fields number smaller than
- Get the child category ID of current category
- Related Posts Excluding Certain Categories
- Unlimited Page Sitemap Link
- Custom query does not find pages
- Custom taxonomy in WP_Query not working
- Add category to my get_post query
- Display posts ONLY from the current logged in user and current week/year/month Elementor posts
- How to use custom page for all posts with custom url, call another directory?
- Pagination repeating posts on search results
- Change normal grids to masonry grids
- order posts by a secondary query that counts items
- How to use wp query in my custom page without including header and footer in wordpress
- WP_Query, ACF field and array
- cron job for custom post type not working since WordPress 5
- WP_Query – multiple orderby with a rand field, doesn’t work
- What does $temp do?
- query not working for ordering by meta_key
- Insert wp_query after the_content with plugin (filter the_content won’t work)
- WordPress pagination not returning posts on second page
- Query 3 meta_key and orderby
- Is instantiating WP_Query not possible within an admin Ajax call?
- How can I use a specific wordpress page template if certain words are used in page title [closed]
- wp-query with a tax-query relation of NOT
- Custom query using WP_Query is not working
- Calling body_class and wp_nav_menu for a different post
- Category Archive not working for pages
- Custom query on custom table fails
- Get closest event where meta_key field is an array
- Can’t get the_content to show
- Get a list of the last posts grouped by author and filtered by category
- Sort by name – second wp_query
- How to query post ids liked by the Author
- Meta_query weird behaviour
- Modify query after meta value
- WP query with multiple custom meta not respecting orderby
- Why ignore_sticky_posts argument is in sticky post query?