Hi,
I would like to know how to customize or change this action which permits to exclude the featured post :
/* Include or exclude featured articles in loop
/* ------------------------------------ */
if ( ! function_exists( 'alx_pre_get_posts' ) ) {
function alx_pre_get_posts( $query ) {
// Are we on main query ?
if ( !$query->is_main_query() ) return;
if ( $query->is_home() ) {
// Featured posts enabled
if ( ot_get_option('featured-posts-count') != '0' ) {
// Get featured post ids
$featured_post_ids = alx_get_featured_post_ids();
// Exclude posts
if ( $featured_post_ids && !ot_get_option('featured-posts-include') )
$query->set('post__not_in', $featured_post_ids);
}
}
}
}
add_action( 'pre_get_posts', 'alx_pre_get_posts' );
My problem is that it deals only with the main query, and I would like it to work for some custom queries (created on my homepage). I read that the pre_get_posts method can be only used for the main query, so is there any other solution to do that for a custom query ?