Wordpress自定义帖子类型处理,下一个,上一个

时间:2017-09-03 09:46:59

标签: php wordpress custom-post-type

所以,我有一个自定义帖子类型'成功案例'。 这些职位按类别分类。事情是,现在客户只有3个成功案例帖子,分为3类。我想要的是创建下一个/上一个按钮,链接到按日期排列的下一个/上一个帖子。 正常的next_post_link();previous_post_link();函数不起作用,除非帖子具有相同的类别,但它们不具有相同的类别。 我查了一下,无法在这里或其他任何地方找到答案。 如果你想要更多连接,这里是link to one post :) 谢谢。

1 个答案:

答案 0 :(得分:0)

我也因为自定义帖子的分页链接而被卡住了一次。希望您能找到以下有用的代码:

$(document).ready(function(){
        var username = $("title").html();
        $.post("functions/userdetails.php", {username: username},
        function(result){
          if(result == 'nf'){
              alert("The Account Doesnt Exist");
          }
          else{
                  var obj = JSON.parse(result);
                  $.each(obj, function(key, val) {          // iterate over results
                  $("#name").html(val.fname+" "+val.lname);
                  $("#bio").html(val.bio);
                  $("#username").html("@"+val.username);
                  $("#tid").html(val.id);
                });

                //here is the first ajax calls completes succesfully and your 
                //new html is build so second ajax must be called from here

                    var tid = $("#tid").html();
                    var myid = $("#myid").html();
                    $.post("functions/checkrelations.php", {tid: tid, myid:myid},
                    function(result){
                          if(result == 'nf'){
                              $("#sendr").show();
                              $("#cancel").hide();
                          }
                          else{
                              $("#cancel").show();
                              $("#sendr").hide();
                            }       
                        }               
                );
           }
        }
    );
});
相关问题