OK, donc je suis à environ 90% fait, la seule partie qui continue à casser, c'est quand j'essaie d'exclure un terme de taxonomie spécifique.
Panne:
Tri: ('v_sort' => 'vues') Cela se fait via le populaire plugin WP-Postviews.
Types de publications: publication, vidéos, musique, albums.
Date: Les 30 derniers jours.
Terme de taxonomie exclu: Taxonomie = contenu, Terme = indy.
Le code de ce qui fonctionne jusqu'à présent.
<?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(); ?>
Comment pourrais-je exclure le terme de taxonomie de contenu indy? Je suis un débutant.
Tu peux essayer:
$the_query = new WP_Query( array(
'posts_per_page' => '5',
'v_sortby' => 'views',
'post_type' => array( 'post', 'music', 'videos', 'albums' ),
'tax_query' => array(
array(
'taxonomy' => 'content',
'field' => 'slug',
'terms' => array( 'indy' ),
'operator' => 'NOT IN'
)
)
));
exclure le terme indy
dans la taxonomie content
.
Résolu.
<?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 = new WP_Query( array(
'posts_per_page' => '5',
'v_sortby' => 'views',
'post_type' => array( 'post', 'music', 'videos', 'albums' ),
'tax_query' => array(
array(
'taxonomy' => 'content',
'field' => 'slug',
'terms' => array( 'indy' ),
'operator' => 'NOT IN'
)
)
));
remove_filter( 'posts_where', 'filter_where' );
// The Loop
while ( $the_query->have_posts() ) :
$the_query->the_post(); ?>
<a class="widget-post-title" href="<?php the_permalink() ?>" rel="bookmark">
<?php the_title(); ?></a>
<a class="thumbnails-link" href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> </a>
<?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(); ?>