Get_Posts, only if in both categories

Use WP_Query‘s category__and: $args = array( ‘posts_per_page’ => 5, ‘category__and’ => array( 93, 85 ) ); $my_query = new WP_Query( $args ); while( $my_query->have_posts() ): $my_query->the_post(); the_title(); endwhile; wp_reset_postdata();

Query random post from different categories

Random ordering is quite expensive operations in SQL and can become a headache on very big sites. Getting a random post from a category for 6 categories will mean you might need to run 6 separate queries, each ordered randomly. This can really break the bank and leave you bankrupt. From your answer and looking … Read more

Get latest posts from multiple categories

2 choices here, you either need to set the category as an array e.g. $args = array( ‘posts_per_page’ => 5, ‘category’ => array(15,16,17,18,19) ); You can’t just add the numbers in a list but I can’t find any documentation that the category element allows multiples (as the name is category) The other option is to … Read more

Cache Get_posts

You can use transient cache to cache your custom query. Here is a simple code to set_transient cache for your query for 12 hours. In 12 hours WordPress will not make new query but fetch posts from transient. On expiration, it will save new query in transient again for next 12 hours. I have been … Read more

Trouble using get_post

possibly: $related_posts = MRP_get_related_posts( $post->ID ); if( $related_posts ) foreach( $related_posts as $key=>$value ) { //only holds the following information: //echo $key; //the related_post_id //echo $value; //the related post title echo get_the_title($key); echo get_the_post_thumbnail($key); } (edited after downloading and testing the plugin)

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