previous_image_link 看起来它使用了adjacent_image_link.
你可能可以通过这篇文章做更多的事情ID
. 此示例显示如何获取上一篇文章和下一篇文章,然后从文章缩略图中获取任何图像数据。
虽然这并不能直接回答您的问题,但我很有信心您可以使用ID
得到你需要的东西。显然,这个额外的功能需要$post_id
但你可以通过get_post_ID()
如果您想要或使用get_previous_post()
和get_next_post
直接地
此示例基于此问题Get Previous & Next posts by Post ID.
function get_next_post_id( $post_id, $is_next=true ) {
return get_previous_post_id($post_id, ! $is_next );
}
function get_previous_post_id( $post_id, $is_prev=true ) {
// Get a global post reference since get_adjacent_post() references it
global $post;
// Store the existing post object for later so we don\'t lose it
$oldGlobal = $post;
// Get the post object for the specified post and place it in the global variable
$post = get_post( $post_id );
// Get the post object for the previous post
$previous_post = $is_prev ? get_previous_post() : get_next_post();
// Reset our global object
$post = $oldGlobal;
if ( \'\' == $previous_post )
return 0;
return $previous_post->ID;
}
$post_id = 6331;
$prev_post_id = get_previous_post_id( $post_id );
$next_post_id = get_next_post_id( $post_id );
var_dump ( array(
\'****** POST ID\',
$prev_post_id,
$post_id,
$next_post_id,
\'****** POST TITLE\',
get_post($prev_post_id)->post_title,
get_post($post_id)->post_title,
get_post($next_post_id)->post_title,
\'****** IMAGE ID\',
$p_img_id = get_post_thumbnail_id( $prev_post_id ),
$c_img_id = get_post_thumbnail_id( $post_id ),
$n_img_id = get_post_thumbnail_id( $next_post_id ),
\'****** IMAGES\',
wp_get_attachment_image( $p_img_id ),
wp_get_attachment_image( $c_img_id ),
wp_get_attachment_image( $n_img_id ),
\'****** IMAGE META\',
wp_get_attachment_metadata( $p_img_id ),
wp_get_attachment_metadata( $c_img_id ),
wp_get_attachment_metadata( $n_img_id ),
\'****** IMAGE POST META\',
get_post_meta( $p_img_id ),
get_post_meta( $c_img_id ),
get_post_meta( $n_img_id ),
));
Reference