SHOW:
|
|
- or go back to the newest paste.
1 | <!-- Query - 1 post from each category no duplication --> | |
2 | <?php $do_not_duplicate = array(); | |
3 | <!-- Featured is first --> | |
4 | <?php $my_query = new WP_Query('category_name=featured&posts_per_page=1'); | |
5 | - | $do_not_duplicate = $post->ID; ?> |
5 | + | |
6 | $do_not_duplicate[] = $post->ID; ?> | |
7 | <?php | |
8 | // Get the ID of a given category | |
9 | $category_id = get_cat_ID( 'Featured' ); | |
10 | // Get the URL of this category | |
11 | $category_link = get_category_link( $category_id ); | |
12 | ?> | |
13 | <article> | |
14 | <header> | |
15 | <h1><a href="<?php echo esc_url( $category_link ); ?>">// Featured</a></h1> | |
16 | </header> | |
17 | <div class="related-thumb"> | |
18 | <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail( 'cat-post-thumb'); ?></a> | |
19 | </div> | |
20 | <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2> | |
21 | <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> | |
22 | <p><?php the_excerpt(); ?></p> | |
23 | </article> | |
24 | <?php endwhile; ?> | |
25 | ||
26 | - | <?php $my_query = new WP_Query('category_name=top-three&posts_per_page=1'); |
26 | + | |
27 | <?php $my_query = new WP_Query(array('category_name' => 'top-three', 'posts_per_page' =>1, 'post__not_in' => $do_not_duplicate)); | |
28 | - | $do_not_duplicate = $post->ID; ?> |
28 | + | |
29 | $do_not_duplicate[] = $post->ID; ?> | |
30 | <?php | |
31 | // Get the ID of a given category | |
32 | $category_id = get_cat_ID( 'top-three' ); | |
33 | // Get the URL of this category | |
34 | $category_link = get_category_link( $category_id ); | |
35 | ?> | |
36 | <article class="centre-margin"> | |
37 | <header> | |
38 | <h1><a href="<?php echo esc_url( $category_link ); ?>">// Top Three</a></h1> | |
39 | </header> | |
40 | <div class="related-thumb"> | |
41 | <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail( 'cat-post-thumb'); ?></a> | |
42 | </div> | |
43 | <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2> | |
44 | <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> | |
45 | <p><?php the_excerpt(); ?></p> | |
46 | </article> | |
47 | <?php endwhile; ?> | |
48 | ||
49 | - | <?php $my_query = new WP_Query('category_name=arts&posts_per_page=1'); |
49 | + | |
50 | <?php $my_query = new WP_Query(array('category_name' => 'arts', 'posts_per_page' => 1, 'post__not_in' => $do_not_duplicate)); | |
51 | - | $do_not_duplicate = $post->ID; ?> |
51 | + | |
52 | $do_not_duplicate[] = $post->ID; ?> | |
53 | <?php | |
54 | // Get the ID of a given category | |
55 | $category_id = get_cat_ID( 'Arts' ); | |
56 | ||
57 | and so on |