Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * The template for displaying Category Archive pages.
- *
- * @package WordPress
- * @subpackage Twenty_Eleven
- * @since Twenty Eleven 1.0
- */
- get_header(); ?>
- <section id="primary">
- <div id="cat-content" role="main">
- <?php
- // Create a new filtering function that will add our where clause to the query
- // Retrieve consistent random set of posts with pagination
- function mam_posts_query($query) {
- global $mam_posts_query;
- if ($mam_posts_query && strpos($query, 'ORDER BY RAND()') !== false) {
- $query = str_replace('ORDER BY RAND()',$mam_posts_query,$query);
- }
- return $query;
- }
- add_filter('query','mam_posts_query');
- function filter_where( $where = '' ) {
- // posts in the last 120 days
- $where .= " AND post_date > '" . date('Y-m-d', strtotime('-120 days')) . "'";
- return $where;
- }
- $seed = date('Ymdh');
- global $mam_posts_query;
- add_filter( 'posts_where', 'filter_where' );
- $mam_posts_query = " ORDER BY rand($seed) "; // Turn on filter
- $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
- $totalpostcount = count(query_posts(array('posts_per_page'=>-1,'cat'=>6) ) );
- $offset = ($paged-1) * 9;
- query_posts( array('paged'=> $paged ,'posts_per_page'=>9,'cat'=>6,'orderby'=>'rand','offset' => $offset, ) );
- $wp_query->found_posts=$totalpostcount;
- $wp_query->max_num_pages = ceil($totalpostcount / 9);
- $mam_posts_query = ''; // Turn off filter
- remove_filter( 'posts_where', 'filter_where' );
- $counter=1;
- if ( have_posts() ) :
- while ( have_posts() ) : the_post();
- if($counter==1||$counter==4||$counter==8) echo '<ul class="cat-col-' . $counter . '">';
- if($counter==1||$counter==9) echo '<li class=type-3>';
- if($counter==2||$counter==3||$counter==4||$counter==5) echo '<li class=type-1>';
- if($counter==6||$counter==7||$counter==8) echo '<li class=type-2>';
- echo '<a href="' . get_permalink( ) . '"><span class="lower"></span><span class="upper"><strong>' . get_the_title() . '</strong><em>View image »</em></span>';
- if($counter==1||$counter==9) the_post_thumbnail('cat-large-square', array('class' => 'cat-large-square'));
- if($counter==2||$counter==3||$counter==4||$counter==5) the_post_thumbnail('cat-small-square', array('class' => 'cat-small-square'));
- if($counter==6||$counter==7||$counter==8) the_post_thumbnail('cat-rect', array('class' => 'cat-rect'));
- echo '</a></li>';
- if($counter==3||$counter==7||$counter==9) echo '</ul>';
- $counter++;
- endwhile;?>
- <div class="nav-previous"><?php previous_posts_link( __( '<span class="meta-nav">←</span>Go Back', 'twentyeleven' ) ); ?>
- </div>
- <div class="nav-next"><?php next_posts_link( __( 'More in this Gallery<span class="meta-nav">→</span>', 'twentyeleven' ) ); ?></div>
- <?php /* twentyeleven_content_nav( 'nav-below' ); */ ?>
- <?php else : ?>
- <article id="post-0" class="post no-results not-found">
- <header class="entry-header">
- <h1 class="entry-title"><?php _e( 'Nothing Found', 'twentyeleven' ); ?></h1>
- </header><!-- .entry-header -->
- <div class="entry-content">
- <p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven' ); ?></p>
- <?php get_search_form(); ?>
- </div><!-- .entry-content -->
- </article><!-- #post-0 -->
- <?php endif; ?>
- </div><!-- #content -->
- </section><!-- #primary -->
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement