Support » Themes and Templates » Help on query_posts() Show only specific category

  • flicker07

    (@flicker07)


    Hello to all,

    i have this query_posts which displays 8 videos of all category
    query_posts( array ( 'posts_per_page' => 8, 'post_type' => 'portfolio' ) );

    how can i modify it and add condition that it will only display a specific category. Category ID is 5 for example.?

    Thanks a lot 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    http://codex.wordpress.org/Function_Reference/WP_Query#Category_Parameters

    try:

    query_posts( array ( 'posts_per_page' => 8, 'post_type' => 'portfolio' , 'cat' => 5) );

    esmi

    (@esmi)

    Forum Moderator

    query_posts( array ( 'cat' => 5, posts_per_page' => 8, 'post_type' => 'portfolio' ) );

    flicker07

    (@flicker07)

    Hello, i tried the codes you’ve given however it doesn’t work. ahmmm. maybe because it is not a post. actually this a custom page which is portfolio. In portfolio i made this entries not on page or posts. we all know that page doesn’t have any category that’s why i used portfolio to sort things up.
    any more suggestions?

    Thanks a lot for your responses 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Help on query_posts() Show only specific category’ is closed to new replies.