Is there a way I can hide a certain categories content from just the homepage Posts section of my Wordpress Site? So, those posts are still posted and live; just not visible nor accessible from the homepage posts area. I'm calling the category twice on the homepage; once in the header within a plugin I'm using, and the other where the posts are created by default by Wordpress. How can I hide my 'featured' category in the main page content of recent posts on the homepage?
-
What exactly do you mean by "homepage"? Are you referring to the Site Front Page specifically, or to the Blog Posts Index, whether displayed on the Site Front Page or not?– Chip BennettNov 1, 2011 at 18:21
-
Thanks for the response; I'm not sure the exact name of the area. But looking at; wordpress.org/extend/themes/twentyten The old twenty ten theme. The main wider area on the left, that populates with posts as you create them. I just want to prevent a certain category from appearing there. But I want them to still exist, just not displaying there.– Lieutenant DanNov 1, 2011 at 21:16
-
Sure... but in what context do you want to do this? Always? Only on the site front page? Some other context?– Chip BennettNov 1, 2011 at 21:20
-
I'm using a header/slider plug-in that calls that category to populate it; it's setup that the header links to those posts within said category. I want this to remain in tact across the site's header; I just don't want the category to be present anywhere else without accessing the links within my header plug-in to get there.– Lieutenant DanNov 1, 2011 at 21:27
-
Does the slider always appear in the header, or only on the front page?– Chip BennettNov 1, 2011 at 21:42
|
Show 1 more comment
1 Answer
Okay, it sounds like you'll want to modify the primary Loop using query_posts()
, but only on the Site Front Page.
I don't think TwentyTen includes a front-page.php
template file, so we'll modify index.php
directly. Add the following code to index.php
, anywhere before the Loop output:
<?php
// Determine if we're on the site Front Page
if ( is_front_page() ) {
// Globalize $wp_query
global $wp_query;
// Create argument array in which we
// exclude desired category IDs. Categories
// are listed as a comma-separated string.
// e.g. '-3', or '-1,-2,-3'
$exclude_cats = array( 'cat' => '-3' );
// Merge custom arguments with default query args array
$custom_query_args = array_merge( $wp_query->query, $exclude_cats );
// Query posts using our modified argument array
query_posts( $custom_query_args );
} // is_front_page()
?>