Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function add_jquery_to_head(){
- wp_deregister_script('jquery');// unregister default wp jquery
- wp_register_script('jquery','http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');//set our version as the new jquery
- wp_enqueue_script('jquery');// then load it
- }
- add_action('template_redirect', 'add_jquery_to_head');
- /* original sorting function from : http://blog.rutwick.com/use-jquery-to-reorder-your-wp-posts-on-the-fly */
- function change_amt_archive(){
- /* If this is a cat archive */
- if (is_category()){
- $cat = get_term_by('name', single_cat_title('',false), 'category');
- $archivetax ='category';
- $archivetype = $cat->slug;
- $catid = $cat->term_taxonomy_id;
- }//if cat
- if( isset($_GET['a']) && $_GET['a'] != ''){
- $amt = $_GET['a'];
- switch($amt){
- case '10':
- $amtper = '10';
- break;
- case '50':
- $amtper = '50';
- break;
- case 'all':
- $amtper = '-1';
- break;
- }}
- else{ //default
- $amtper = '10';
- }
- ?>
- Amount Per Page:
- <select id="amt-per">
- <option value="10" <?php echo (!isset($amt) || $amt == '' || $amt == '20')? 'selected="selected"':''; ?>>10</option>
- <option value="50" <?php echo ($amt == '50')? 'selected="selected"':''; ?>>50</option>
- <option value="all" <?php echo ($amt == 'all')? 'selected="selected"':''; ?>>View All</option>
- </select>
- <script type="text/javascript">
- var amtper = jQuery('#amt-per');
- var str;
- amtper.change(function(){
- str = jQuery(this).val();
- window.location.href = "<?php echo site_url(); ?>/<?php echo $archivetax ?>/<?php echo $archivetype ?>/?a="+str;
- });
- </script>
- <?php
- $args = array(
- 'cat' => $catid,
- 'posts_per_page' => $amtper
- );
- query_posts( $args );
- ?>
- <?php
- }//end change_amt_archive
- ?>
- <?php /* temlate tag - paste above archive loop in archive.php template
- if(function_exists('change_amt_archive')) :
- change_amt_archive();
- endif;
- */ ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement