Wordpress: Check if there are previous posts before displaying link

前端 未结 4 1672
逝去的感伤
逝去的感伤 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:32

    for people checking this in 2013, get_previous_post has been depreciated.

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

    I used to use this :/

    if(get_next_post()) { echo 'next'; }
    if(get_previous_post()) { echo 'last'; }
    

    But now I use this :)

    if(get_next_posts_link()) { echo 'next'; }
    if(get_previous_posts_link()) { echo 'last'; }
    

提交回复
热议问题