Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have mainly protected categories, but I have one open category, how can I set it up so I load only the open catgeory posts to show on my home page

share|improve this question
    
WE NEED MOAR INFORMATIONZ - how are you protecting categories? A plugin? Which one? Are you using a public theme or your own? –  TheDeadMedic Jan 13 '12 at 22:55
    
I'm using the UAM to protect the categories and the theme is Third Style 1.1.1 –  Jonnny Jan 13 '12 at 22:56

2 Answers 2

up vote 0 down vote accepted

This should about do it for you, add args as needed

$args = array(
    //basic post data
    'posts_per_page' => 10,
    'post_type'      => 'post',
    'post_status'    => 'publish',
    //category
    'category_name'  => 'your-cat-slug'
);
$posts = new WP_Query( $args );

Docs: WP_Query

share|improve this answer
    
Thank you, does this go in the loop.php file? –  Jonnny Jan 13 '12 at 23:22
    
Really depends on your setup...loop.php isn't even a default file, so you'll have to figure that out on your own, but I would guess it does. The Loop documentation should help you out. –  m0r7if3r Jan 13 '12 at 23:46

It would be better to filter the query on the home page instead of adding another one with WP_Query

add_filter( 'pre_get_posts', 'my_home_query' );
function my_home_query( $query ) {
 if( $query->is_home ) {
       $query->set( 'cat', $cat_id );
   }
     return $query;
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.