Skip to content

Instantly share code, notes, and snippets.

@senlin
Created March 6, 2014 00:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save senlin/9379704 to your computer and use it in GitHub Desktop.
Save senlin/9379704 to your computer and use it in GitHub Desktop.
Custom controls in the theme customizer using WP_Query() instead of query_posts(). Article on http://code.tutsplus.com/articles/custom-controls-in-the-theme-customizer
<div id="posts">
<?php
// Get category ID from Theme Customizer
$catID = get_theme_mod( 'tcx_category' );
// Only get Posts that are assigned to the given category ID
$args = array(
'post_type' => 'post',
'cat' => $catID
);
$catquery = new WP_Query( $args );
// The loop
if ( $catquery->have_posts() ) {
while ( $catquery->have_posts() ) {
$catquery->the_post();
the_title();
the_excerpt();
the_category();
echo '<hr />';
} // while
} // if
wp_reset_postdata();
?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment