Wordpress: Check if there are previous posts before displaying link

前端 未结 4 1670
逝去的感伤
逝去的感伤 2021-01-05 01:03

I\'m using the following code to display a \'previous posts\' link on my Wordpress blog.

     
4条回答
  •  生来不讨喜
    2021-01-05 01:21

    Just to be clear:

    Colin's answer isn't correct in my opinion. get_previous_post is not deprecated, previous_post is.

    http://codex.wordpress.org/Function_Reference/get_previous_post http://codex.wordpress.org/Function_Reference/previous_post

    For me the use of get_next_post works still fine for me.

    if(get_next_post()) {  }
    if(get_previous_post()) {  }
    

提交回复
热议问题