View Single Post
Old 11-06-2011, 06:07 PM  
vdbucks
Monger Cash
 
Industry Role:
Join Date: Jul 2010
Posts: 2,773
Quote:
Originally Posted by tonyparra View Post
Thanks i did get it to work
If you want to add a category clause to it.. you could add something like the following to the args array...

via category id:
PHP Code:
$args1 = array(
        
'cat'            => 3,
        
'posts_per_page'    => 5,
        
'orderby'        => 'rand',
        
'post_status'        => 'publish',
        
'offset'        => 0
    
);
query_posts($args1); 
of course, you could also just use the category name like so:
PHP Code:
$args1 = array(
        
'category_name'        => 'cat_name_here',
        
'posts_per_page'    => 5,
        
'orderby'        => 'rand',
        
'post_status'        => 'publish',
        
'offset'        => 0
    
);
query_posts($args1); 
or my favorite way, by category slug because I don't like using uppercase letters and/or spaces in my queries:
PHP Code:
$Obj get_category_by_slug('cat_slug_here');
$catid $Obj->term_id;
$args1 = array(
        
'cat'             => $catid,
        
'posts_per_page'    => 5,
        
'orderby'        => 'rand',
        
'post_status'        => 'publish',
        
'offset'        => 0
    
);
query_posts($args1); 
vdbucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote