Support » Themes and Templates » Custom Sticky Post for Each Category

  • I have been through all the posts here about stickies in categories and don’t see what I need, so I’m starting a new thread and hope you can help.

    I want to have a sticky post for the top of each category. This post should be in the currently viewed category, and I would like to have the code also include another category…

    So, top post in Technology would be from both Technology and Giveaways categories.

    Top in Home Goods would be from Home Goods and Giveaways categories, etc.

    The second category will always be the same… Giveaways, and the first will always be whatever is currently being viewed.

    Is there code or a plugin to do this?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Are these category views utilizing the archive.php or how are you arranging the loop to display each category?

    They will be using the archives template. The theme we’re using is News (child theme of Genesis) from StudioPress. I couldn’t find a category page template, so I’m assuming on the Archives…

    I’m not sure if we’d put the code in the Simple Hooks for Genesis, or directly into the archives.php file… whichever works best!

    Looking at this:

    i’m not seeing a method to allow the archives to display the sticky posts at the top of the category list using the standard archive loop..


    maybe ignore_sticky_posts=0 passed through add_action(‘pre_get_posts’) with an (is_archive()) conditional might force it to

    I just tried it with custom loops in my themes archive.php and the ignore_sticky_posts=0 didn’t work.

    I’m unable to figure that out, might be a main blog loop only sort of thing where it doesn’t work on is_archive or is_search, not sure

    however, if you created your own category templates based on the cat you could probably have that as part of the wp_query to not ignore the sticky posts ordering

    the orderby doesn’t specify you can order by the asci with sticky posts either.. yeah i’ve got nothing besides it’s own loop remade via a category template

    Using WordPress as a CMS, I needed the sticky posts to display on the top of the page per category and then display the rest of the post (in the category) in alphabetical order by title.

    I ended up running 2 loops, 1 for sticky post and 1 without. I created a category.php file and I’m using the follow queries:

    // get the current category
    $category = get_the_category();
    // get the sticky post in the category, order by title - ascending
    query_posts(array( 'post__in' => get_option('sticky_posts'), 'orderby' => 'title', 'order' => 'ASC' , 'cat' => ''.$category[0]->cat_ID.'' ));
    Do your loop for posts.....
    //We all ready have the category array
    // get all the posts (non-sticky) in this category order by title - ascending
    query_posts(array( 'post__not_in' => get_option('sticky_posts'), 'orderby' => 'title', 'order' => 'ASC' , 'cat' => ''.$category[0]->cat_ID.'' ) );
    Do your loop for posts.....

    This is the solution that worked for me. I’m guessing there might be a easier way to do this, but I couldn’t find one.


    &caller_get_posts=0 shows sticky post at top of page but it shows all posts on index page with out pagination. Pagination works only on normal posts.

    Anyone have idea to show sticky post on top with pagination ? For e.g. if i have total 100 posts and 30 of them are sticky. Post per page sets to 10 than for first 3 pages, it should show sticky posts and than after normal post of rest of 7 pages.

    Basically i need to show post order by sticky post.

    Any help ?

    Rakshit Patel.
    PHP Programmer India

    Pretty much as described I am after this same feature. What I want to do is something similar to what “simplyworks” suggests above. But I don’t know how to implement the Do your loop for posts... as he suggests. I just want to use the standard loop that exists, I don’t even want/need to change any styling, I just want the stickies to the top of the category…

    PLUS… I do want to remove the stickies from the front page. I just don’t want them there–I realise that’s where they are intended, but, like the OP, I only want them appearing at the top of the relevant category.

    • So, I’m thinking I need the category.php file
    • I want to loop thru and get the stickies first
    • I then want to go thru again and get the non-stickies

    So far, it’s just how simply works describes. But for the loop part, what do I put there? Is that the get_template_part(“loop”,”category”); or something similar? Or do I have to create something unique here?

    Also, how to hide all stickies from the front page? I’m thinking one of two scenarios:

    1. either change the front page to omit this–I don’t know how
    2. not use the “sticky” option in the first place and create a category called “sticky” <– I’m liking this option more

    With the second option above, I would modify the original query (somehow) so that the first call calls posts that are a member of the original calling category PLUS the sticky category… Then the second call would be to posts that are of the original calling category THAT ARE NOT in the sticky category.

    I just don’t know how to implement it.

    I’m not really asking for someone to do it for me, I just don’t know 1) how to construct the loop (if that’s what I need to do) and 2) how to construct that query.

    I have searched (that is how I found this topic) and this has been the clearest (by simplyworks) solution so far. I just need it expanded ‘slightly’ 🙂

    Any help appreciated, thanks

    Is/are there any plugin(s) that can do this?

    You can also try AStickyPostOrderER

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Custom Sticky Post for Each Category’ is closed to new replies.