dimanche 28 décembre 2014

Pre_get_posts to exclude latest posts of a custom taxonomy, can't find the error


I am trying to exclude the latest three posts which have the custom taxonomy "video" from the homepage loop.


The hook I have written is the following:



function main_loop_excludes($queryhome){
$arg = array( 'numberposts' => '3', 'tax_query' => array(
array(
'taxonomy' => 'post_type',
'field' => 'slug',
'terms' => 'video',
)
) );
$latest_featured = wp_get_recent_posts( $arg );
if($queryhome->is_home()){
$queryhome->set('post__not_in',array($latest_featured[0]["ID"]));
}
}
add_action('pre_get_posts','main_loop_excludes');


But the problem is that I get blank page. Can you find the error? Thanks in advance!





Aucun commentaire:

Enregistrer un commentaire