Home  >  Article  >  Backend Development  >  wordpress 获取上一篇 下一篇文章参数

wordpress 获取上一篇 下一篇文章参数

WBOY
WBOYOriginal
2016-06-06 20:51:051225browse

获取上一篇:previous_post_link(),获取下一篇:next_post_link()

参数:
1、当前文章同一分类下的上下文章
2、上下一篇文章标题、链接、特色图像

如果只是参数1,官方有示例:

不知道有没有什么方式获取参数2的要求。

wordpress 获取上一篇 下一篇文章参数
上图是要得效果,那两个缩图是WordPress上/下篇文章的特色图像,the_post_thumbnail();调用的 ,下面的标题和链接是上面的代码调用的,特色图像是手动调的,我想要自动调用上/下篇文章的特色图像和链接地址

回复内容:

获取上一篇:previous_post_link(),获取下一篇:next_post_link()

参数:
1、当前文章同一分类下的上下文章
2、上下一篇文章标题、链接、特色图像

如果只是参数1,官方有示例:

不知道有没有什么方式获取参数2的要求。

wordpress 获取上一篇 下一篇文章参数
上图是要得效果,那两个缩图是WordPress上/下篇文章的特色图像,the_post_thumbnail();调用的 ,下面的标题和链接是上面的代码调用的,特色图像是手动调的,我想要自动调用上/下篇文章的特色图像和链接地址


				
				

好人做到底.
自己看着修改吧.

function nav_link_with_thumb(){
         $output = '';
         $prev_post = get_previous_post();
         if ($prev_post){
         	 $output .= get_the_post_thumbnail($prev_post->ID, 'thumbnail');
             $prev_post->filter='sample';
             $output .= 'Previous Post: '.$prev_post->post_title.'';
         }
         $next_post = get_next_post();
         if ($next_post){
             $output .= get_the_post_thumbnail($next_post->ID, 'thumbnail');
             $next_post->filter='sample';
             $output .= 'Next post: '.$next_post->post_title.'';
         }
         echo $output;
}

能支持下tab吗?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn