OK so I’m about 90% done, the only part that keeps breaking is when I try to exclude a specific taxonomy term.
Break down:
Sorting: (‘v_sort’ => ‘views’) This is being done via the popular WP-Postviews plugin.
Post Types: post, videos, music, albums.
Date: The last 30 days.
Excluded Taxonomy Term: Taxonomy = content, Term = indy.
The code of what works thus far.
<?php
// Create a new filtering function that will add our where clause to the query
function filter_where( $where = '' ) {
// posts in the last 30 days
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
return $where;
}
add_filter( 'posts_where', 'filter_where' );
// The Query
$the_query = new WP_Query( array(
'posts_per_page' => '5',
'v_sortby' => 'views',
'post_type' => array( 'post', 'music', 'videos', 'albums' ) )
);
remove_filter( 'posts_where', 'filter_where' );
// The Loop
while ( $the_query->have_posts() ) :
$the_query->the_post(); ?>
I'm doing stuff here...
<?php endwhile;
/* Restore original Post Data
* NB: Because we are using new WP_Query we aren't stomping on the
* original $wp_query and it does not need to be reset.
*/
wp_reset_postdata(); ?>
How would I exclude the content taxonomy term indy? I’m a beginner btw.
You can try:
to exclude the
indy
term in thecontent
taxonomy.Solved.