本帖最后由 pootor 于 2013-5-19 20:16 编辑
luguokankan 发表于 2013-5-19 20:00
你的问题是不是不会搞包含sort参数的 pagination? 加sort参数的分页可以搞定。
不能搞定:不加参数,可以实现用下拉列表实现访客排序,但是排序不能分页,访问第二页排序就失去作用了。能否解决分页也能排序(不加参数)?下面的代码可以实现排序,但不能分页。- <?php
- $order = "&order=DESC";
- if ($_POST['select'] == 'tag') { $order = "&tag=mytag"; }
- if ($_POST['select'] == 'title') { $order = "&order=ASC&orderby=title"; }
- if ($_POST['select'] == 'newest') { $order = "&order=DESC"; }
- if ($_POST['select'] == 'oldest') { $order = "&order=ASC"; }
- if ($_POST['select'] == 'mcommented') { $order = "&order=DESC&orderby=comment_count"; }
- if ($_POST['select'] == 'lcommented') { $order = "&order=ASC&orderby=comment_count"; }
- ?>
- <form method="post" id="order">
- Sort reviews by:
- <select name="select" onchange='this.form.submit()'>
- <option value="tag"<?php selected( $_POST['select'],'tag', 1 ); ?>>Tag</option>
- <option value="title"<?php selected( $_POST['select'],'title', 1 ); ?>>Title</option>
- <option value="newest"<?php selected( $_POST['select'],'newest', 1 ); ?>>Newest</option>
- <option value="oldest"<?php selected( $_POST['select'], 'oldest', 1 ); ?>>Oldest</option>
- <option value="mcommented"<?php selected( $_POST['select'],'mcommented', 1 ); ?>>Most commented</option>
- <option value="lcommented"<?php selected( $_POST['select'],'lcommented' , 1 ); ?>>least commented</option>
- </select>
- </form>
- <?php query_posts($query_string . $order); ?>
- <?php if ( have_posts() ) : ?>
- <?php while (have_posts()) : the_post(); ?>
复制代码 |