Skip to content

Instantly share code, notes, and snippets.

@cccamuseme
Created May 19, 2017 19:08
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 cccamuseme/4749ea110faa0300a7d761a7e3243322 to your computer and use it in GitHub Desktop.
Save cccamuseme/4749ea110faa0300a7d761a7e3243322 to your computer and use it in GitHub Desktop.
Change color of title based on category
<?php
// The Query
$the_query = new WP_Query( array( 'cat' => '3,4', 'posts_per_page' => 4 ) );
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<h4><a href="' . get_permalink($recent["ID"]) . '">' . get_the_title() . '</a></h4>';
echo '<div class="post-meta">';
echo the_time('F j, Y | g:i a');
echo '</div>';
echo '<p>' . get_the_excerpt() . '</p>';
}
/* Restore original Post Data */
wp_reset_postdata();
} else {
// no posts found
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment