Are there sub-systems in WordPress that would employ data structures beyond CPT that a `get_posts` won’t be able to catch?

Actually if you look closely to the codex, you can see that setting ‘post_type’ argument to any will by default leave out some post types from the query: https://codex.wordpress.org/Class_Reference/WP_Query#Type_Parameters ‘any’ – retrieves any type except revisions and types with ‘exclude_from_search’ set to true. So you can actually register a post type and make it non-public, … Read more

`get_posts()` ignore my custom post

If we do not specify post types, WordPress searches only ‘posts’ $actus_new = get_posts( array( ‘post_type’ => array( ‘cantine’, ‘post’ ), ‘post__in’ => $ids, ‘posts_per_page’ => 5, ) );

var_dump and print_r cause white screen

Actually, memory was exhausted. Someone has copy-pasted an actual 2MB base64-encoded image into the post content, var_dump was trying to output it. Had to delete the image via PHPMyAdmin, because the WP editor won’t open. Once it had been deleted, the problem was gone.

If clauses in get_posts query

only retrieve posts with that meta key: $rand_posts = get_posts(array( ‘numberposts’ => 4, ‘orderby’ => ‘rand’, ‘post_type’ => ‘ansatte’, ‘order’ => ‘ASC’, ‘meta_key’ => ’employee_pic’, )); or maybe use WP 3.1’s meta_query: $rand_posts = get_posts(array( ‘numberposts’ => 4, ‘orderby’ => ‘rand’, ‘post_type’ => ‘ansatte’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ => ’employee_pic’, ‘value’ … Read more

making random query button using $_GET

You cannot use the direct class methods have_posts() or the_post() unless you’re working with the main query. In order to modify the main query you must use query_posts. If you want to create a new query object you need to call those methods from the new query object as Rarst showed in his example. So … Read more