How do you Query posts with nothing in common?

Maybe you’re looking for the post__in parameter in WP_Query. $query = new WP_Query(array( ‘post__in’ => array(23,18,2,199,6,8) ); And then: while ( $query->have_posts() ) { $query->the_post(); /* post loop */ } Take a look at the docs. =D For public queries: post__in is not public queryable by default, so you can just validate and copy $_GET[‘post__in’] … Read more

How would I get 1 latest post from a query for 5 posts?

You can use $current_post property of WP_Query $query_args = array( “posts_per_page” => “5” ); $listedPosts = new WP_Query($query_args); // the loop if ( $listedPosts->have_posts() ) { while ( $listedPosts->have_posts() ) { $listedPosts->the_post(); if ( (int) $listedPosts->current_post === 0 ) { // loop content for hero post } else { // loop content for remaining posts … Read more

posts_per_page => 1 shows 2 posts

Most probably you have a sticky post there. If you want exact number of posts you need to ignore sticky posts. So your query should look like this: query_posts( array( ‘orderby’ => ‘rand’, ‘posts_per_page’ => 1, ‘ignore_sticky_posts’ => 1, ) ); or as suggested, never use query_posts() $query = new WP_Query( array( ‘orderby’ => ‘rand’, … Read more

meta query not showing any results?

you’re missing an array within the meta_query element: $args = array( ‘post_type’ => ‘programmes’, ‘meta_query’ => array( array( ‘key’ => ‘linktovideocatchup’, ‘value’ => ”, ‘compare’ => ‘NOT LIKE’ ) ) ); (this is required to allow for querying of multiple meta fields.) you also had an extraneous comma after the meta_query array element which can … Read more

Query posts without a specific ID

Most of the things you can do with a query are described in the Codex page for WP_Query You need to use the ‘post__not_in’ parameter eg: $args = array( ‘post__not_in’ => array(’34’,’54’), // post ids ‘post_type’ => ‘page’ );`

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)