First, don’t use query_posts()
. Just get rid of the call entirely. It will break things.
Second:
I tried adding the following before the query_posts ( function but it does nothing.
Callbacks and add_action()
calls belong in functions.php
, not in the template file. If you’ve put it directly in home.php
, remove it from there, and put it in functions.php
.
Third:
Your pre_get_posts()
filter uses the if ( is_feed() )
conditional. The is_feed()
conditional returns true when an RSS feed is being output, not on the blog posts index (which is what is output via home.php
). Try using is_home()
instead.
Fourth:
Don’t call set_query_var()
inside your callback. Use $query->set()
instead.
Putting it all together
Use the following in functions.php
<?php
function wpse55358_filter_pre_get_posts( $query ) {
// Let's only modify the main query
if ( ! is_main_query() ) {
return $query;
}
// Modify the blog posts index query
if ( is_home() ) {
// Exclude Category ID 1
$query->set( 'cat', '-1' );
// Build featured posts array
$featured_posts_array = featured_posts_slider();
// Exclude featured posts
$query->set( 'post__not_in', $featured_posts_array );
}
// Return the query object
return $query;
}
add_filter( 'pre_get_posts', 'wpse55358_filter_pre_get_posts' );
?>
Questions
What category are you trying to exclude? Are you sure the ID is 1
?