You have posts_per_page = -1, which means show unlimited posts. Change the -1 to the number of posts you want to appear.
Also you have output that skips if your “next_open_day” meta value is null, but the query will only run 3 times, so you need to move that logic into the query itself by using these arguments in the query_posts().
<?php
$metakey = 'next_open_day';
$args = array('post_type' => 'page',
'post_parent' => 2,
'posts_per_page' => 3,
'orderby' => 'title',
'order' => 'ASC',
'meta_query' => array(
array('key' => $metakey,
'value' => '',
'compare' => '!='
)
)
);
query_posts($args);
?>
Related Posts:
- Order by meta value or date?
- Filtering posts by post meta data
- Custom query with query_posts doesn’t show post without certain meta_key
- How to sort by meta value?
- get_post_meta causes database queries
- Querying posts with meta value that begins with a certain pattern
- IF.. post meta show… Conditional Tag Help…?
- order posts by meta value on posts page
- Query_post($args)
- query_posts() on key’s value, or key’s existence
- How to retrieve an array of post IDs by a particular value stored in a custom meta’s array
- Query posts by meta_key whose value is an array
- Exclude posts by post meta value
- Frontend form with multiple posts
- query_posts orderby postmeta [closed]
- Ordering Posts By Meta Data
- get all posts with certain meta data
- how to query posts by category and tag?
- How do I query by post format in WordPress 3.1
- How to set posts per page using WP_Query()
- How do I create a random post that will last for a day
- Query Custom Meta Value with Increment
- Custom Post Type “Event”: chronological list of recurring events
- Order by meta value, pro first, then free
- Having trouble generating pagination links on custom query
- How to create an attachments archive with working pagination?
- query_posts and pagination, still stuck after much research
- Query posts by taxonomy term name
- Sorting problem with ‘query_posts’ funcion in wordpress. Sort by custom field not working
- how could I get the pagination as I want to when query posts using get_posts function
- Counter code for paginated category pages in wordpress
- Author List page: Exclude based on last post date
- Replace query_posts with pre_get_posts
- query_posts sort in multiple directions
- Filter query_posts by tag slug on “Tag Archive” page (when tag is 2 or more words)
- Warning: urlencode() expects parameter 1 to be string, array given in and not getting the preffered output
- Show Posts From Same Category OR Same Tag
- Using database meta_values to calculate new post order using pre_get_posts or a ‘request’ hook
- exclude ids through post__not_in
- Integrating post archive wtih another source and preserving date ordering
- Order posts using a custom array
- How can I sort homepage by a meta value?
- WordPress query_posts and orderby page order
- How do I correctly get all posts within the last year using the query_posts function?
- Show Only Posts Owned By Logged In User + my post
- Custom MySQL Query with logic
- Get post and all posts after it by ID?
- trouble with query to fetch next and previous posts
- how to make members list directory through wordpress post custom meta key.
- How do I make query use exact post title
- WordPress tax_query not showing private posts
- WordPress /page/2 not working
- Simple custom post query for all the posts or many of them not working
- Hook to return true when the_post() is used in a custom while loop
- My post repeats itself on the second page [closed]
- How to remove a plugin filter’s priority on specific loops (custom queries)?
- Proper syntax to add boolean in array()
- get_the_title outputs title until spacing; it does not get full length of title
- using query_posts to pull posts out of a category in a while loop. Getting odd echo
- Echo a numerical value in query_posts
- why to use query_posts() in custom page?
- Query posts to get all but the most recent post
- Always using the same ARRAY on different querys
- How to show the number of each post has been read in a while loop?
- Modify loop but keep the original query, what am I doing wrong?
- Post per page not working if no category specified
- How do I use pagination in WordPress?
- Does WordPress run a post query when a page is invoked?
- wp_query with ajax
- Multiple posts/pages in one page?
- Weird problem on if statement
- How to check a list or feed of all posts under a category and tag?
- Issue with sidebar widgets not showing when I do custom queries
- Why would post_type be ignored in this query?
- query_posts call sets is_home() to true
- Calling Posts from Specified Cat
- Script that gets the first tag of post and query all other posts with the same tag
- Trouble highlighting correct menu parent with wp_nav_menu classes while viewing “single posts”
- How do I add a timezone offset to this query?
- query_posts thumbnail condition
- Show posts from specific roles
- How to add an “or” instead of and “and” (&) in a WordPress query?
- Latest 5 post excerpts from 5 different authors in Sidebar
- Instead of 4 loops, how can I do it better?
- Modify main loop query for paged and meta key
- wordpress query_posts featured page always on top
- Need to add a space after meta value in query_posts in wordpress for zipcode search
- Tax query get first product with attribute value in pre_get_posts
- I need query_posts() to order results first by a meta value and then by post ID
- No duplicate tags by category
- why is pre_get_posts not working
- If meta_key has value = 6 | Change the wp_posts.post_date to current date
- Query posts based on parents attribute
- Adding Category Argument into an Array for WordPress Query
- orderby not working for query_posts using array of IDs
- The_content display a different content from a previous loop
- Run second query on page based on author of the first query
- Why doesn’t this page query work?
- Resetting a Query using wp_reset_query() or wp_reset_postdata() does not work
- How to get custom post type posts with certain multiple tags names and category id?