i have the following code to get the next and the previous article.
if(wp_get_post_parent_id($post->ID)){
$pagelist = get_pages('post_parent='.wp_get_post_parent_id($post->ID));
$pages = array();
foreach ($pagelist as $page) {
$pages[] += $page->ID;
}
$current = array_search($post->ID, $pages);
$prevID = $pages[$current-1];
$nextID = $pages[$current+1];
}
With the $nextID and $previID I am able to create a link like here:
<a title="<?php echo get_the_title( $prevID ); ?>" href="<?php echo get_permalink($prevID); ?>"><?php echo get_the_title( $prevID ); ?> »</a>
Now i want to also have the featured image of this $prevID and $nextID. I don't know why, but it does not work. I tried the following:
echo wp_get_attachment_url(get_post_thumbnail_id($prevID));
How can i do that? Even if i add the fix ID like 1253 instead of $prevID, it does not work. When i use $post->ID (of the current article, just to check), it works.
Any idea?