Created
March 9, 2013 11:11
-
-
Save jegtnes/5123868 to your computer and use it in GitHub Desktop.
Example of filtering by multiple categories and tags with a custom WP Query
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
<?php | |
$categories = $_GET( 'categories' ); | |
$tags = $_GET( 'tags' ); | |
$query = new WP_Query( | |
array( 'cat' => $categories ), | |
array( 'tags' => $tags ) | |
); | |
while ( $query->have_posts() ) : | |
$query->the_post(); | |
echo '<li>' . get_the_title() . '</li>'; | |
endwhile; | |
?> | |
<a href="/?tags=cake,cookie,baking&categories=14,92,16">Link to custom query</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment