Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- Query - 1 post from each category no duplication -->
- <?php $do_not_duplicate = array();
- <!-- Featured is first -->
- <?php $my_query = new WP_Query('category_name=featured&posts_per_page=1');
- while ($my_query->have_posts()) : $my_query->the_post();
- $do_not_duplicate[] = $post->ID; ?>
- <?php
- // Get the ID of a given category
- $category_id = get_cat_ID( 'Featured' );
- // Get the URL of this category
- $category_link = get_category_link( $category_id );
- ?>
- <article>
- <header>
- <h1><a href="<?php echo esc_url( $category_link ); ?>">// Featured</a></h1>
- </header>
- <div class="related-thumb">
- <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail( 'cat-post-thumb'); ?></a>
- </div>
- <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
- <time datetime="<?php echo the_time('j-m-Y'); ?>" pubdate><?php echo ''.get_the_time('j').' '.''.get_the_time('M').' '.get_the_time('Y').''; ?></time>
- <p><?php the_excerpt(); ?></p>
- </article>
- <?php endwhile; ?>
- <!-- Top 3 -->
- <?php $my_query = new WP_Query(array('category_name' => 'top-three', 'posts_per_page' =>1, 'post__not_in' => $do_not_duplicate));
- while ($my_query->have_posts()) : $my_query->the_post();
- $do_not_duplicate[] = $post->ID; ?>
- <?php
- // Get the ID of a given category
- $category_id = get_cat_ID( 'top-three' );
- // Get the URL of this category
- $category_link = get_category_link( $category_id );
- ?>
- <article class="centre-margin">
- <header>
- <h1><a href="<?php echo esc_url( $category_link ); ?>">// Top Three</a></h1>
- </header>
- <div class="related-thumb">
- <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail( 'cat-post-thumb'); ?></a>
- </div>
- <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
- <time datetime="<?php echo the_time('j-m-Y'); ?>" pubdate><?php echo ''.get_the_time('j').' '.''.get_the_time('M').' '.get_the_time('Y').''; ?></time>
- <p><?php the_excerpt(); ?></p>
- </article>
- <?php endwhile; ?>
- <!-- Arts -->
- <?php $my_query = new WP_Query(array('category_name' => 'arts', 'posts_per_page' => 1, 'post__not_in' => $do_not_duplicate));
- while ($my_query->have_posts()) : $my_query->the_post();
- $do_not_duplicate[] = $post->ID; ?>
- <?php
- // Get the ID of a given category
- $category_id = get_cat_ID( 'Arts' );
- and so on
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement