get next next post in single.php

I really need your help. in my single.php I had to get the next post in the same category (which i already have by: $in_same_cat = true; $excluded_categories=””; $previous = false; $next_post = get_adjacent_post($in_same_cat,$excluded_categories,$previous);) now I need the next next post and also in the opposite direction previous previous post thanx 3 Answers 3 See … Read more

Using previous_post_link and next_post_link to wrap around post sequence

For a single custom post type, I’m using previous_post_link and next_post_link with simple arrows. (Although text arrows are shown here, in the actual I’m using graphics with the text hidden via CSS.) Code: <nav class=”arrowNav”> <div class=”nav-previous”> <?php previous_post_link(‘%link’, ‘«’); ?> </div> <div class=”nav-next”> <?php next_post_link(‘%link’, ‘»’); ?> </div> </nav> This works fine except for … Read more

Showing Thumbnail from Previous and Next Posts

Is there a simple way to use the post thumbnail when calling previous_post_link() and next_post_link()? 1 Answer 1 This could be acheived by using the get_previous_post() and get_the_post_thumbnail() functions. Then just pass the thumbnail value into the second parameter of previous_post_link(). $prevPost = get_previous_post(); $prevThumbnail = get_the_post_thumbnail( $prevPost->ID ); previous_post_link( ‘%link’, $prevThumbnail );

Post in Multiple Categories to stay in current category (permalink, next previous post link)

I guess this has been mentioned before, but after 2 days of browsing i haven’t find a complete solution. Maybe someone has come across this problem before? I’m building a designer portfolio where posts are assigned to more than one categories. Permalinks are set in the form of: portfolio.com/category-name/post-name/ Example: Post 1 Assigned to Category … Read more

WordPress previous_post_link exclude posts with multiple categories

I have a single-news page in WordPress where I am looping over all the posts and conditionally updating the previous and next buttons to exclude certain categories based on the current post’s category ID. Here is what I have: <?php if (have_posts()): ?> <?php while (have_posts()): ?> <?php the_post(); ?> <?php if ( in_category(7)) : … Read more

adding custom fields to next and previous post link

Im trying to make my next and previous post buttons display my custom field but for some reason it doesnt display the custom field its just blank. Heres my code. <div id=”next-prev-links”> <?php $previous_post = previous_post_link(‘%link’, ”.$image_prev.”, TRUE); $next_post = next_post_link(‘%link’,”.$image_next.”, TRUE); $image_prev = get_post_meta( $previous_post->ID, ‘image’, true); $image_next = get_post_meta( $next_post->ID, ‘image’, true); ?> … Read more

How to show next Post Thumbnail image in WordPress using current post id

i make a wordpress theme i make a grid structure show below i have this grid structure it contain two rows and every row has three column i want to show my wordpress random posts in this grid this is my code <div class=”row”> <div class=”col-xs-12″> <div class=”rst-mediagrid”> <div class=”div”> <?php $args = array( ‘posts_per_page’ … Read more

Why is previous_post_link and next_post_link working outside of the Loop?

This is my single.php file: I’m using previous_post_link(); and next_post_link();. In the Worpress codex it says that it only works inside the loop. <?php /** * The Template for displaying all single posts. * * @package WordPress * @subpackage Starkers * @since Starkers 3.0 */ get_header(); ?> <?php get_sidebar(); ?> <div id=”content”> <?php // Create … Read more