0

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

1 Answer 1

0

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

get_query_var('cat')

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.