Hot answers tagged get-posts
slug is not a valid query paramter, so get_posts() will just return X latest posts! Use name instead. http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters
You overwrite the value of $post when you output the first set of posts, so it's no longer the same post object as your single post. You can either wp_reset_postdata() after each loop (which you should do after the last one anyway), or assign $post->ID to some other var before the loop, and reference that instead so it doesn't get overwritten.
More complex way I use it this way (I'm usually doing one page design, however the method of loading pages is still same). Fo Theme options, I'm using Option tree plugin where my clients could just checkbox which pages should appear there (it's passed by it's ID) and than I load it into the script. <?php // loading pages which should appear by option ...
Your syntax is incorrect for your date_query. It should be an array of an array, not just an array. I also suspect that your problem might be related to PHP and not Wordpress. Your before date is invalid. PHP only supports dates between 13 December 1901 and 19 January 2038, so your dates need to between those two dates. For reference, see date You would ...
Your issue is not with storage, it is with retrieval. get_post_custom() is inconvenient and rarely used in practice. get_post_meta() is more common in practice. Note it has explicit argument to retrieve a single value, rather than array of values for a key (which WP can do too).
As stated in comments Most probably your posts per page setting for your site is less than 10 One have to remember, get_posts uses WP_Query. Any new instance of WP_Query and the main query (which also uses WP_Query) uses the value set for Blog pages show at most as default for the posts_per_page parameter when this parameter is not explicitly set by ...
Only top voted, non community-wiki answers of a minimum length are eligible