Hi,
website is http://www.pgmsemblog.com
can we make a sticky post in the category archive pages?
i read about a way to do it by adding category description. But would prefer a post to be sticky there so it is easy for editing.
any help will be appreciated.
Thanks
Ravi
This will get one sticky post for the current category being viewed:
<?php
$cat = get_query_var('cat');
$args=array(
'post_type' => 'post',
'post_status' => 'publish',
'post__in'=>get_option('sticky_posts'),
'category__in'=> array ($cat),
'showposts' => 1,
'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
endwhile;
} //if ($my_query)
wp_reset_query(); // Restore global post data stomped by the_post().
?>