Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <? /* List posts from the same categories - start */
- global $post;
- $cats=array();
- foreach(get_the_category() as $category) {
- $cats[]=$category->cat_ID;
- }
- $showposts = 1; // -1 shows all posts
- $do_not_show_stickies = 1; // 0 to show stickies
- $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
- $args=array(
- 'category__in' => $cats,
- 'caller_get_posts' => $do_not_show_stickies,
- 'posts_per_page' => 1,
- 'paged' => $paged
- );
- $temp = $wp_query; // assign orginal query to temp variable for later use
- $wp_query = null;
- $wp_query = new WP_Query($args);
- while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
- <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
- <header>
- <h2><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
- <?php the_title(); ?>
- </a></h2>
- <?php if ( 'post' == get_post_type() ) : ?>
- <div class="entry-meta">
- <?php twentyeleven_posted_on(); ?>
- </div>
- <!-- .entry-meta -->
- <?php endif; ?>
- </header>
- <!-- .entry-header -->
- <div class="entry-summary">
- <?php the_excerpt(); ?>
- </div>
- <!-- .entry-summary -->
- </article>
- <!-- #post-<?php the_ID(); ?> -->
- <?php endwhile; ?>
- <div class="navigation">
- <div class="alignleft">
- <?php next_posts_link('« Older Entries') ?>
- </div>
- <div class="alignright">
- <?php previous_posts_link('Newer Entries »') ?>
- </div>
- </div>
- <?php $wp_query = $temp; //reset back to original query ?>
- <?php /* List posts from the same categories - end */?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement