Cache Get_posts

I have a query (see below) that gives a list of 10 news items ordered by the meta value “event_date” and filtered so that only posts earlier than today are displayed. This query is taking two seconds to process, so I am looking for a simple way to cache the results to get the load … Read more

How Can i Get 5 Recent Post Title With Corresponding Link?

I Want to Add My Latest 5 Post Title with Corresponding Link in My Header Position.What was the Actual Php code?Am Newbie …. 2 Answers 2 This sounds like an additional Loop on that page, right? You might want to use: <ul> <?php $posts_query = new WP_Query(‘posts_per_page=5’); while ($posts_query->have_posts()) : $posts_query->the_post(); ?> <li><a href=”https://wordpress.stackexchange.com/questions/20489/<?php the_permalink(); … Read more

Use post__in and post__not_in together?

I’m trying to only show posts that a user hasn’t seen, like this: $exclude = array(1,2,3); $include = array(3,4,5); $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 30, ‘post__in’ => $include, ‘post__not_in’ => $exclude, ‘orderby’ => ‘post__in’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => … Read more

Using query_posts inside single.php loop

Inside of my loop in single.php, I used a custom query using get_posts to return posts belonging to a certain category. <?php global $post; $paged = get_query_var( ‘paged’ ) ? get_query_var( ‘paged’ ) : 1; $myposts = get_posts(“paged=$paged&category=5”);?> <?php foreach($myposts as $post) :?> <?php the_title();?> <?php endforeach; ?> The problem is that the original loop, … Read more

Trouble using get_post

For Microkids related post plugin He said “Using the get_post() function you could get any data you need from the related posts.” and he posted this snippet of code. $related_posts = MRP_get_related_posts( $post_id ); I’m not exactly sure how to use the get_post feature for this situation. I would like to display the titles and … Read more