0

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?

2
  • As in, only show posts from the news category?
    – mor7ifer
    Commented Jan 28, 2012 at 0:05
  • Yes, only allowing that category. Commented Jan 28, 2012 at 0:13

1 Answer 1

1
$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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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