Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php get_header(); ?>
- <?php global $do_not_duplicate; //NEW DECLARATION in the header part of the code ?>
- <?php $do_not_duplicate = array();
- $my_query = new WP_Query(array('posts_per_page' => 3, 'post__in' => get_option( 'sticky_posts' ), 'caller_get_posts' => 1 ) );
- while ($my_query->have_posts()) : $my_query->the_post();
- $do_not_duplicate[] = $post->ID; ?>
- <?php
- $category = get_the_category();
- if ($category) {
- echo '<a href="' . get_category_link( $category[0]->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category[0]->name ) . '" ' . '>' . $category[0]->name.'</a>';
- }
- ?>
- <br>
- <a href="<?php the_permalink() ?>" rel="bookmark" title="Read: <?php the_title(); ?>"><?php the_title(); ?></a>
- <br>
- <?php endwhile;?>
- <?php wp_reset_query(); ?>
- <br>
- <br>
- <?php global $do_not_duplicate; //NEW DECLARATION in te index.php part of the code ?>
- <?php $my_query = new WP_Query(array('posts_per_page' => 4, 'post__not_in' => array_merge($do_not_duplicate, get_option( 'sticky_posts' )) ) );
- while ($my_query->have_posts()) : $my_query->the_post();
- $do_not_duplicate[] = $post->ID; ?>
- <a href="<?php the_permalink() ?>" title="Read: <?php the_title(); ?>"><?php the_title(); ?></a><br>
- <br>
- <?php endwhile;?>
- <?php wp_reset_query(); ?>
- <br>
- <br>
- <?php
- //for each category, show 1 post
- $cat_args=array(
- 'orderby' => 'name',
- 'order' => 'ASC'
- );
- $categories=get_categories($cat_args);
- foreach($categories as $category) {
- $args=array(
- 'numberposts' => 1,
- 'post__not_in' => array_merge($do_not_duplicate,get_option( 'sticky_posts' )),
- 'category__in' => array($category->term_id)
- );
- $posts=get_posts($args);
- if ($posts) {
- $ncat = '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>';
- foreach($posts as $post) {
- setup_postdata($post);
- $do_not_duplicate[] = $post->ID; ?>
- <a href="<?php the_permalink() ?>" title="Read: <?php the_title(); ?>"><?php the_title(); ?></a><br>
- <br>
- <?php the_excerpt(); ?><br>
- <br>
- By <?php the_author_link(); ?>, <?php the_time('F j, Y'); ?> | In: <?php echo $ncat ?><?php comments_popup_link('<b>No Comments</b>', '<b>1 Comment</b>', '<b>% Comments</b>', '', '<b>Comments off</b>'); ?><br>
- <br>
- <?php
- } // foreach($posts
- } // if ($posts
- } // foreach($categories
- ?>
- <?php wp_reset_query(); ?>
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement