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.

Forgive me if this is too basic of a question...

I am using Twenty Eleven and am wanting to only allow my "news" category show on the front page, excluding all other categories.

How can I do this?

share|improve this question
    
As in, only show posts from the news category? –  m0r7if3r Jan 28 '12 at 0:05
    
Yes, only allowing that category. –  Keith Groben Jan 28 '12 at 0:13
add comment

1 Answer

up vote 1 down vote accepted
$args = array(
    //post basics
    'post_status'    => 'publish',
    'post_type'      => 'post',
    'posts_per_page' => 10
    //order
    'orderby'        => 'date',
    'order'          => 'desc',
    //category query
    'tax_query'      => array(
        array(
            'taxonomy' => 'category',
            'field'    => 'slug',
            'terms'    => 'news' //make this the slug of the category you want to use
        )
    )
);
$posts = new WP_Query( $args );

$posts will now contain 10 posts from news. You can tweak this as you see fit, it's pretty simple to do, and WP_Query is INCREDIBLY powerful.

Docs: WP_Query

share|improve this answer
add comment

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.