Skip to content

Instantly share code, notes, and snippets.

@ckunte
Created September 20, 2011 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckunte/1229661 to your computer and use it in GitHub Desktop.
Save ckunte/1229661 to your computer and use it in GitHub Desktop.
WordPress page template for curated posts (for making a portfolio, or a projects page)
<?php
/*
Template Name: Curated posts
*/
?>
<?php
// Begin main loop to list page's static content:
if ( have_posts() ) :
while ( have_posts() ) :
the_post();
?>
<?php // Page TITLE and (editable) CONTENT ?>
<h2>
<a href="<?php the_permalink() ?>"
rel="bookmark"><?php the_title(); ?></a>
</h2>
<?php
the_content('Read on &#155;');
endwhile;
?>
<?php // BEGIN first SPECIAL loop:
// Displays posts that have both the following
// tags: stories, noteworthy. (Group 1)
$tpair1 = "stories+noteworthy";
$grp1 = new WP_Query('tag=$tpair1&showposts=-1');
?>
<h2>Noteworthy stories</h2>
<table>
<?php
while($grp1->have_posts()) :
$grp1->the_post();
?>
<tr class="post <?=($i%2)?"color1":"color2";$i++;?>">
<td class="lcol"><?php the_date('M d, Y'); ?></td>
<td class="rcol"><a href="<?php the_permalink() ?>"
rel="bookmark"><?php the_title(); ?></a>
<?php { the_excerpt(); } ?>
<span><?php the_category(', ') ?></span>
</td>
</tr>
<?php endwhile; ?>
</table>
<?php // END first special loop ?>
<?php // BEGIN second SPECIAL loop:
// Displays posts that have both the following
// tags: articles, misc. (Group 2)
$tpair2 = "articles+misc";
$grp2 = new WP_Query('tag=$tpair2&showposts=-1');
?>
<h2>Miscellaneous articles</h2>
<table>
<?php
while($grp2->have_posts()) :
$grp2->the_post();
?>
<tr class="post <?=($i%2)?"color1":"color2";$i++;?>">
<td class="lcol"><?php the_date('M d, Y'); ?></td>
<td class="rcol"><a href="<?php the_permalink() ?>"
rel="bookmark"><?php the_title(); ?></a>
<?php { the_excerpt(); } ?>
<span><?php the_category(', ') ?></span></td>
</tr>
<?php endwhile; ?>
</table>
<?php // END second special loop ?>
<?php else : ?>
<h2>Not found</h2>
<p><?php _e("Sorry, not found."); ?></p>
<?php
endif;
// End main loop to list page's
// static content.
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment