i know that : <?php $pagename = get_query_var('name'); ?>
get the name of the current page/post. But I dont know how to get the name of the next and the previous post. I will use it for a hover tip and the alt of the image that will lead to the previous/next post
1 Answer
$prev = get_previous_post();
$next = get_next_post();
$prev_title = $prev ? get_the_title($prev) : 'Current is First Post';
$next_title = $next ? get_the_title($next) : 'Current is Last Post';
See get_previous_post and get_next_post on Codex for some details and additional params you can use.
-
it work, but please explain me the notation ... i dont know this short way of writing php... please make the long version so i can learn... thanks Commented Aug 31, 2013 at 0:51
-