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.

I have styled an archive page to display one sticky post at the top with special design, and then to display all the rest of the posts in that category (except the sticky post) listed in standard title/excerpt format. I have specified the target category for both loops:

Sticky only:

<?php $args = array(
'cat' => 3,
'posts_per_page' => 1,
'post__in'  => get_option( 'sticky_posts' ),
'ignore_sticky_posts' => 1              
    );

query_posts( $args );?>

All the rest:

<?php 
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$sticky = get_option( 'sticky_posts' );                     
$args = array(
    'cat' => 3,
    'ignore_sticky_posts' => 1,
    'post__not_in' => $sticky,
    'paged' => $paged,
    'orderby' => 'menu_order',  
    'order' => 'ASC' 
); 
query_posts( $args ); ?>

I have made custom category.php templates for each category with the 'cat' ID added manually in each loop.

My question: Is it possible to do this without manually setting the cat ID? I have tried but end up with all posts rather than just the category variable. thx - Steve

share|improve this question

1 Answer 1

you can get the category ID of a category archive with:

get_query_var('cat')
share|improve this answer

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.