Created
March 6, 2014 00:25
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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