get_previous_post in same categories

get_previous_post uses get_adjacent_post() which has a bunch of filter hooks you can use but a much simpler approach would be to create your own function, something like this: // Create a new filtering function that will add our where clause to the query function date_filter_where( $where=”” ) { global $post; $where .= ” AND post_date … Read more

Next/Prev posts on same page

Pass Paged into parameter array of query_posts You should set get_query_var( ‘paged’ ); if you want your query to work with pagination. $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args_news= array( ‘cat’ => 1, ‘posts_per_page’ => 2, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘numberposts’ => -1, ‘paged’ => $paged, ); query_posts( $args_news ); if ( … Read more

Loop – how to get previous/next post for first/last post?

You can loop the slides quite simply: $prev_index = ( $loop->current_post == 0 ) ? count( $loop->posts ) – 1 : $loop->current_post – 1; $next_index = ( $loop->current_post == count( $loop->posts ) – 1 ) ? 0 : $loop->current_post + 1; $prev_post = $loop->posts[ $prev_index ]; $next_post = $loop->posts[ $next_index ]; echo $next_post->post_title; echo $next_post->post_title; … Read more