douyouqian8550
2016-08-04 16:31
浏览 34
已采纳

将图像ACF与get_previous_post一起使用

In an article I want to have the link of the previous article, including the title of the article and a ACF custom image. I now how to make the link of the previous title project :

<?php
$prev_post = get_previous_post();
if (!empty( $prev_post )): ?>
<a href="<?php echo $prev_post->guid ?>">
<?php echo $prev_post->post_title ?>            
</a>
<?php endif ?>

Here's my ACF code for the current image :

<?php 
$image = get_field('image_cover');
if( !empty($image) ): ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php endif; ?>

But how to do the same thing (get_previous_link) for my ACF image ?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题