[resolved] Category Sticky (5 posts)

  1. picard102
    Posted 6 years ago #

    So here is what I'm trying to do.

    On the category archive pages I want to have sticky posts in that category appear at the top of the page and the paginated pages, and then follow that with the normal display of posts and pagination for that category.

    I figured I could do this with a post query to call the sticky, and then another query after to display the normal order of posts.

    I can't seem to get the code quite right though. Anyone know of a better solution, or the right php to use to make this work?

  2. MichaelH
    Posted 6 years ago #

    This in a Category Template works to show the sticky posts for a given category:

    $cat = get_query_var('cat');
      'post__in' => $sticky,
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <small><?php the_time('m.d.y') ?></small> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
        //this is necessary to show the tags
        global $wp_query;
        $wp_query->in_the_loop = true;
  3. Frank Anthony
    Posted 5 years ago #

    Whats the easiest way to make posts Sticky for a category separate from the home page. I know I can hard code which post numbers I don't want to show, but that's not really an option I like.

    I have only one post I want sticky for the home page but other posts I want sticky in their category pages.

    Do we still need a plugin to accomplish this?

  4. Superhearing
    Posted 5 years ago #

    I am looking for the same thing.

  5. invisibleillness
    Posted 5 years ago #

    I'm looking too

Topic Closed

This topic has been closed to new replies.

About this Topic