Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RESOURCE LIBRARY EXAMPLE:
- HTML:
- <div class="sort">
- <a href="/resources/?sort=alpha">alpha</a> |
- <a href="/resources/?sort=recent">recent</a> |
- <a href="/resources/?sort=oldest">oldest</a>
- </div>
- PHP:
- <?php
- wp_reset_query();
- $args = array(
- 'post_type' => 'resource',
- 'posts_per_page' => -1,
- );
- if (isset($_GET['sort']))
- {
- if ('alpha' == $_GET['sort'])
- {
- $args['orderby'] = 'title';
- $args['order'] = 'ASC';
- }
- elseif ('oldest' == $_GET['sort'])
- {
- $args['order'] = 'ASC';
- $args['orderby'] = 'date';
- }
- elseif ('recent' == $_GET['sort'])
- {
- $args['order'] = 'DESC';
- $args['orderby'] = 'date';
- }
- }
- query_posts($args);
- ?>
- In your case you could make the sort links (the HTML provided) into numbers for posts per page.
- SORT BY NUMBER OF POSTS:
- EXAMPLE:
- HTML:
- <div class="sort">
- <a href="/resources/?sort=25">25</a> |
- <a href="/resources/?sort=50">50</a> |
- <a href="/resources/?sort=100">100</a> |
- <a href="/resources/?sort=all">All</a>
- </div>
- Then for your args you could do something like the following (I only did 2 of them):
- PHP:
- <?php
- wp_reset_query();
- $args = array(
- 'posts_per_page' => -1,
- 'orderby' => DESC,
- );
- if (isset($_GET['sort']))
- {
- if ('25' == $_GET['sort'])
- {
- $args['posts_per_page'] = '25';
- }
- elseif ('all' == $_GET['sort'])
- {
- $args['posts_per_page'] = '99999999';
- }
- }
- query_posts($args);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement