显示博客文章页面的下一页和上一页

我在Webflow CMS中有一个博客,我想在其中显示带有链接的上一个和下一个博客标题。 到目前为止,我的代码在下面,但是我做错了,因为它两次显示了标题。

<style>#post_list{display: none;}</style>

<script>
  var Webflow = Webflow || [];
  Webflow.push(function () { 
    
    var next_href = $('#post_list .w--current').parent().next().find('a').attr('href');
    var previous_href = $('#post_list .w--current').parent().prev().find('a').attr('href');
    var next_title = $('#post_list .w--current').parent().next().find('a').text();
var previous_title = $('#post_list .w--current').parent().prev().find('a').text();
    
    
    //if last post in list
    if(next_href == undefined) {
      next_href = $('#post_list').children().children().first().find('a').attr('href');
      $('#next_button').fadeOut(); //optional - remove if you want to loop to beginning
    }
    
    //if first post in list
    if(previous_href == undefined) {
      previous_href = $('#post_list').children().children().last().find('a').attr('href');
      $('#previous_button').fadeOut();  //optional - remove if you want to loop to end
    }
    
    //apply hrefs to next / previous buttons
    $('#next_button').attr('href',next_href);
    $('#previous_button').attr('href',previous_href);
    $('#next_title').text(next_title);
$('#previous_title').text(previous_title);
    
  });
</script>

我尝试删除各种内容,因此它要么停止工作,显示“标题”,要么出现其他错误。

iCMS 回答:显示博客文章页面的下一页和上一页

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2065033.html

大家都在问