It appears that you’re trying to get the latest 15 posts where the meta key is not equal to ‘None’.
Instead of loading all the posts into memory and then looping through to see if the meta value is not ‘None’, you could use the meta_query parameter.
$args = [
'post_type' => 'post',
'orderby' => 'date',
'order' => 'ASC',
'posts_per_page' => '15',
'meta_query' => [
[
'key' => 'slider_position',
'value' => [ 'None' ],
'compare' => '!=',
],
],
];
$query = new WP_Query( $args );
Related Posts:
- Is it possible to completely stop WP_Query retrieving posts?
- PHP memory friendly alternative to get_posts()
- Using get_posts vs. WP_Query
- How to clear the cache?
- Should I use Transients with W3 Total Cache APC Caching? [closed]
- Duplicate Queries
- wp_transients | wp_object_cache VS SESSIONS & Cookies?
- How to prevent queried posts from being added to cache?
- Transient caching for wp query
- Make WP_Query more efficient?
- How do I force WP_query to fetch fresh, non-cached results?
- How to optimize multiple WP_Query() calls on one page?
- Assign Json file to WP_Query
- Out Of memory issue on post per page parameter
- Should wp_query automatic meta and term cache priming be used in an enviroment with an object caching
- How to cache wp_query with pagination using transients?
- Transient api Caches confused
- How to use WP_Query() on single.php?
- Using Transients
- Save large WP_Query to transient === false
- Check the stored / cached WP_Query with transients on post change
- get_posts query caching?
- Pagination in WP query with transient API
- How to save the results of a query as a php file for an autocomplete search bar
- WP_Query (or WC_Product_Query) out of memory
- WP Query Args – Title or Meta Value
- WordPress Pagination Not Working – Always Showing First Pages Content
- Whats the difference between post_limits and pre_get_posts?
- Order Search Results Page by meta_value If no Value Return Remaining Results
- Query all posts where meta value is empty
- Revolution Slider Orderby Two Custom Fields
- wp query by search in titles only & put the posts in loop
- Get random terms
- Dynamically Override Fancy Title – Part II
- Count posts returned by get_posts in external PHP script
- List the 5 most recent child pages
- Meta-value query
- Complex Orderby Parameters: How to query with multiple orderby parameters using meta_value_num?
- Rewrite rule to prettify two $_GET variables while in a new endpoint from a page
- Creating a custom search for a specific post type
- new WP_Query(), have_posts() return false in user_register hook
- How to filter, restrict and return posts based on custom user meta information
- Masonry, WP_Query & paged – first page repeating, second page not loading
- Query posts intersecting tags and categories
- REST API: Limit Read Permissions for Default Endpoints
- Excluding pages in WP_query using ACF
- How to sort post by custom table value
- Pagination on static Posts page
- Query about wp_query
- wp_query sort with meta_value_num is not working
- how update data through ajax and jquery
- WP_Query arguments relation shows AND instead of OR
- Combine results of multiple WP_Query to resemble single WP_Query
- Using WP_Query() in Magento shows error
- Get All posts by Tag_Id not working, query seems to contain extra term_taxonomy_id
- Is this meta query problematic?
- Utilising an existing page while using the “s” query parameter
- Yoast primary category query modification
- AJAX Breaking Offset Argument In WP Query
- Loop 3 posts column wise and continue the loop into same columns
- Is it possible to retrieve posts depending on meta_key LIKE condition? [duplicate]
- WP Query and date format
- Why is the value zero going in my custom database table?
- function wp() does not use meta_query?
- Query Not working as expected
- How to create single page site in WordPress
- Widgets: Show Recent Posts Only if the Posts Have Both Categories X and Y
- get_children() Archive Template
- What’s the best way to make a blog page on WordPress?
- Populate select list with meta values from all posts of a Custom Post Type
- tax_query not working on custom post type
- Exclude post from wp_query based on custom field boolean
- WordPress Meta Query Null Values Order
- WooCommerce WP_Query using tax_query returns no results (0 = 1)
- WP Query and multiple queries
- How do i query woocommerce booking post type on init action?
- Using something else instead of using 9 wp_query
- make query more simplest and in one query
- How to display post based on which is clicked
- date_query problem
- WP_Query Not Working with Variable
- How to allow Readers to Select Post Order?
- Random posts in WP_Query when searching by tag
- How To Use WP_Query To Get The Custom Post type Posts With Keywords
- 423 queries in 6.098 seconds
- I wan to process the following js to process the AJAX Request on my function to calculate author Total Post views
- (How) Can I use ‘wild cards’ on the left hand side of an array argument?
- Combine privileged users array with my current query
- Get posts from similar time as current post
- Query posts filter not working
- Providing a function to override the default query
- WP_Query do not include posts with a certain value in a custom field –
- Remove 5 latest posts from the loop
- Exclude post formats in custom loop
- get_post_meta bringing back results, but $wpdb->postmeta doesn’t
- WordPress WP_User_Query ignores the `meta_query` when called from an Ajax function
- Unexpected results custom wp_query and $the_query->request;
- Simple Apex Charts with jQuery not working
- post per page for differents post types in a same query
- why same category base and single post base don’t work?