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

Adding Pagination on a Custom Author Page

Put the following code in your functions.php file. function limit_posts_per_page() { if ( is_author() ) // you can limit other pages as well ( i.e. is_archive() ), if need be. return 5; } add_filter( ‘pre_option_posts_per_page’, ‘limit_posts_per_page’ ); Make sure your using the author.php template, otherwise it wont work. Please have a look at twentyten’s author.php … Read more

Is get_posts() more efficient than The Loop?

When WordPress include the category.php (just like any other template) the main query (i.e. the query triggered by the url) is already ran: it means that a query on database was already fired and this is the reason why in a template you can run the Loop without calling a query. If you call get_posts … 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

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

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(); ?>”><?php the_title(); ?></a></li> <?php endwhile; wp_reset_query(); ?> </ul> Also read more here: http://codex.wordpress.org/The_Loop#Multiple_Loops_in_Action

How to show more than 5 posts?

I think you could use the posts_per_page argument in your get_posts query: $args = array( ‘child_of’ => 1 ); $categories = get_categories( $args ); foreach ($categories as $category) { echo ‘<li><a>’.$category->name.'</a>’; echo ‘<ul>’; $posts_args = array( ‘posts_per_page’ => 9, ‘category’ => $category->term_id ); foreach (get_posts($posts_args) as $post) { setup_postdata( $post ); echo ‘<li><a href=”‘.get_permalink($post->ID).'”>’.get_the_title().'</a></li>’; } … 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)