Skip to content

Instantly share code, notes, and snippets.

@soggybag
Created November 27, 2015 19:32
Show Gist options
  • Save soggybag/036ecc733968cc82cd27 to your computer and use it in GitHub Desktop.
Save soggybag/036ecc733968cc82cd27 to your computer and use it in GitHub Desktop.
WordPress WP Query boiler plate
<!-- Use WP Query to get some posts for the home page -->
<div id='' class="">
<?php
// Get an archive of categories with category_name=slug where slug is the slug name for the category
// Add another option to the query following the &
// Use post_per_page=# to set the number of most recent posts to display
$art_post = new WP_Query( "category_name=your-category-name-here&posts_per_page=3" );
if ( $art_post->have_posts() ) : while ( $art_post->have_posts() ) :
$art_post->the_post();
?>
<!-- your content here -->
<?php endwhile; else: ?>
<h3>Woops... no category departments not found ??</h3>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment