调用下一篇日志函数 代码<?php next_post_link(); ?>
这个是个链接格式
<a href="http://127.0.0.1/asd/uncategorized/287.html" class="next" title="标题"><span>内容</span></a>
怎么获取id    287 或者个287.html我想了2个方法  
一个是用php调用数据库里的下一个ID 好像这个有点难。。还有一个是调用函数这个函数   用js寻找next 在截取  287 或者 287.html  请问高手哪个比较快比较好点   有时间的话顺便写个 让我参考下 谢谢!!

解决方案 »

  1.   

    这个冒似不用改的,你开启Apache的伪静态,然后在项目里面配置一下 .htaccess    冒似就可以。
      

  2.   

    1. php的 打开 ./wp-includes/deprecated.php 搜索 “function next_post” 里面的代码大概如下
    $post = get_next_post($in_same_cat, $excluded_categories); if ( !$post )
    return;
    //就是下一个id ,
    $post->ID其中的 $in_same_cat: 是否要在同一个分类下查找下一篇日志,$excluded_categories:排除掉这些分类查找下一篇的id2. js 
    var postid,
        url = $('.next').attr('href').split('/');postid = url[url.length-1].split('.')[0];alert(postid)