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 orderby date not working
- Best way to detect if you are in a SINGLE POST page
- How to do a wp_query using “BETWEEN” with two meta_values?
- Better way to get tag stats?
- Query two taxonomies via URL or link?
- wp_query order by title
- Sort posts by custom taxonomy name
- Wp_query order by multiple custom fields?
- Would this post meta be better added to the post table rather than post_meta table
- meta_query on a date range using an array of values
- Get product list of given category
- wpdb get results doesn’t work with variable
- Query Ignoring ‘exclude’ Parameter?
- How to prevent writing duplicate loops?
- merge two query arguments into one WP_Query call
- Adding a parameter to the default query
- Using WP_Query in “parse_query” or “pre_get_post” in Posts2Posts
- Taxonomy search/filter with multiple taxonomies and multiple taxonomy terms
- While creating Block Themes in WordPress, how can I query custom posts for an Archive view?
- How To Fix WP Query Returns Results But Shouldn’t?
- Weird orderby => post__in issue
- how to handle multiple ajax wordpress queries?
- How to extract specific post
- wp_Qwery works to slow
- Custom post type archive pagination query issue
- 2 weeks ago from meta query meta value
- WP Group posts by year(desc) > month(desc) > date(asc)
- Running main loop 2 times with conditional statement
- paged variable not working for category/custom post archive
- How to output the title of the blogs home page
- Array as ‘key’ in WP_Query
- Check the Specific Meta Key IF its Meta Value is Empty then… (WP Post Meta Query)
- Searching for meta_key returns 0 posts
- Using custom taxonomies in a query
- Determining Author post count
- Apply filters to main query instead of creating new one?
- WP_Query returns different results from get_posts() [closed]
- How to pass query string vars between admin pages?
- Query posts by Post title
- Use title of post as argument for query
- How can I comment comma-separated array values?
- Different Loop for tag pages?
- Orderby two meta fields not working
- Multiple Query_Posts
- WP_Query: attachment image in “full” size?
- Adding pagination to sub-wp_query within a singular post page
- How to _GET multiple value checkbox WP_Query in Custom Toxonomy / Custom Fields
- Make a products only viewable to a specific user ID in meta_query pre_get_posts
- get_post_format is not returning standard
- Duplice post with standard WP loop – fixed by using query_posts() instead
- Get categories within specific term
- Exclude parent categories from recent posts list
- How can I query a radius of coordinates?
- custom excerpt is not being shown
- Filtering WP_Query based on wp_postmeta keys values
- meta_query only check if both value are set
- post_type not working when tag__in is present?
- How to create page that lists tags by initial letter?
- Seach and categories not working when ignoring sticky posts in main loop
- posts_per_page increment additional post
- 3 wp_query on one page with pagination for last query
- WP_Query shows all posts on single post pages
- Display Count of posts
- Optimize WP_Query
- Add a custom variable to query page object
- Read more redirection problem
- Creating Custom Query
- Help in query for list links
- Multiple loops on index page with sticky post and pagination
- WP_Query issues with argument posts_per_page
- Search (Custom Form, Custom Search Result)
- Randomly display posts on a site hosted by WPEngine? [closed]
- Elementor custom query
- How to get all post_id and meta_value using meta_key in wp_postmeta table
- List categories using WP_Query