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