When a post is sticky, it (generally) remains at the top of the published posts list, even if there are newer posts. It is possible to have more than one sticky post.

learn more… | top users | synonyms

0
votes
3answers
1k views

Custom query: how to get the sticky posts first?

I noticed that if I code a custom WP_Query, sticky posts don't show first in the list. So I was wandering how to achieve that. I've almost done it with 3 subsequent queries, but I guess there must be ...
0
votes
0answers
33 views

WP Query with sticky posts and tax_query

I have this query; $posts = new WP_Query(array( 'post_type' => 'post', 'posts_per_page' => 5, )); Which correctly places sticky posts at the beginning. However,...
2
votes
2answers
349 views

Sticky posts on home page, search, tag and archives without plugin

I have a question today. I am looking for a solution to make sticky post available on my website. But, i just got it work on homepage with the code below. function wpb_latest_sticky() { /* Get all ...
2
votes
0answers
19 views

Add a single featured post to all pages?

Within wp-admin, we need the ability to select a single post as the featured post. This featured post will be displayed on all pages. I know I can make a post "sticky" but we would like to have only ...
-1
votes
2answers
40 views

Exclude duplicated $sticky post from combined loop content

Since Wordpress sticky posts feature allow the post checked as sticky in post publish panel to be placed at the top of the front page of posts. I was also intended to style the sticky post differently ...
0
votes
0answers
13 views

Sticky posts with conditional taxonomy check

I have two different taxonomies with the same terms. so let's say: Places: Russia, India, Jamaica. Sticky Places: Russia, India, Jamaica. Now i want to create a loop which checks if a post has two ...
0
votes
1answer
27 views

Sticky Post from page 2 and on

Today I updated an old blog post and set it to sticky to show info about the latest changes. It’s a typical post with Site Updates as the title for a log of a sort you could say, with past changes ...
0
votes
1answer
43 views

Why Wordpress CMS uses an array in wp_options instead of a field for Sticky posts?

In WordPress we can pin (sticky) a post. Wordpress uses an option in wp_options table named 'sticky_posts' with an array list of sticky posts! As a normal condition WordPress should add a field ...
1
vote
1answer
2k views

Sticky post for each category on category pages [duplicate]

I would like to show category.php a post I set as sticky post for that category. Do you know code to do this?
0
votes
0answers
34 views

Sticky post to top of category

I use this code: add_filter('the_posts', 'bump_sticky_posts_to_top'); function bump_sticky_posts_to_top($posts) { foreach($posts as $i => $post) { if(is_sticky($post->ID)) { ...
1
vote
1answer
2k views

Ensuring sticky posts are retrieved first (without using two queries)?

I need to maintain pagination for use with infinite scroll. Is there no way to tell query_posts to retrieve sticky posts first? It seems to be default behaviour on a standard wordpress blog on the ...
3
votes
1answer
81 views

WP_Query: Why is sticky post not first item in loop?

I've got a custom WP_Query loop based of meta_value variables: $meta_cat = get_sub_field('category'); $posts = new WP_Query( array( 'cat' => $meta_cat, 'posts_per_page' => get_sub_field(...
0
votes
1answer
32 views

Make posts non-sticky

I have around 200 posts. I want to make all posts non-sticky except 4 posts. I know the id of those 4 posts. How can I do it? Using plugin or sql query?
0
votes
1answer
348 views

Query *only* sticky posts

I've been using the following query to try to output only posts that are marked as stickies: <?php $args = array( 'post_type' => 'post', 'posts_per_page' => 2, '...
4
votes
1answer
43 views

Apply styling only to first page sticky posts

I'm using the following bit of code to highlight sticky posts: <?php if (is_sticky()) : ?> <div class="col-md-12 box-01"> <div class="content"> <?php endif; ?> The ...
1
vote
0answers
56 views

Blog page Server error 500 with stick post loop in query.php

Using sticky post on site near about 5000 sticky post i have. In wp-includes/query.php here i have bellow snippet code.on line 3748 to 3760.If i comment this code the blog page work properly. if ...
0
votes
2answers
35 views

Images for sticky posts

I have a sticky post that gets the image from background URL, but doesn't resize the image and leaves my blog heavy. Here is the code: // is sticky if ( ( is_home() || is_front_page() ) ) { $...
2
votes
1answer
87 views

Exclude expired sticky posts

I use the following code to exclude expired posts and it works fine but it doesn't exclude expired sticky posts. //* Exclude expired posts add_action( 'pre_get_posts', 'exclude_expired_posts' ); ...
1
vote
0answers
39 views

Make sticky post on save

I am trying to make a post sticky on publish or update based on a custom field. I use the code below but it doesn't work. What am I doing wrong? function stick_post_on_save( $post_id ) { $...
0
votes
1answer
956 views

How to check a post is sticky or not yet?

I want to check a post a post is sticky or not to do some function. Thanks all for help ;)
0
votes
1answer
39 views

Update a post to remove sticky option

I'm working on a plugin that we'll remove posts from the 'sticky posts'. I'll use the post ID to find it. What function should i use to remove the sticky option after i get this post? Something like ...
1
vote
2answers
836 views

Sticky post appears twice

I am trying to modify the number of posts_per_page in the loop. This way: function posts_per_page($query) { $query->query_vars['posts_per_page'] = 3; } add_filter('pre_get_posts', '...
1
vote
1answer
1k views

How can I make a custom post type sticky?

I installed the "Sticky Custom Post Types" plugin, and I added this code to my function.php: function wpb_cpt_sticky_at_top( $posts ) { // apply it on the archives only if ( is_main_query() &...
0
votes
0answers
171 views

Manage sticky post content via the admin panel

I'm working on a theme that I try to make from scratch. Now I want to have two sticky post in my theme which uses for ads purpose. So I want the site owner to have the ability to change the sticky ...
0
votes
0answers
277 views

How to retrieve sticky post with Visual Composer's loop builder?

So I have a simple custom shortcode function build under Visual Composer with vc_map. <?php /** * Blog Posts * */ if( function_exists( 'vc_map_get_attributes' ) ) { $atts = ...
0
votes
2answers
1k views

Only display sticky post or latest post in custom loop

I'm new to Wordpress and PHP and I've been battling with this for a while now. What I have for the moment is 2 loops. I want to first loop to only ever show 1 post: either a sticky post, or the ...
0
votes
1answer
252 views

Exclude first post (sticky or not) from the loop using query_posts()

I'm using query_posts( 'offset=1' ); to exclude the first post from the loop. However, if the first post is a sticky post it will be shown and the second (non-sticky) post will not be shown. Is there ...
2
votes
2answers
142 views

Include Sticky Posts in Page Post Count for custom query

This link solves the problem but it's only for the main query. What if you are using a custom query? How can you modify the answer below: add_action('pre_get_posts', 'ad_custom_query'); function ...
2
votes
2answers
92 views

Query sticky posts with thumbnails

I need to display max 5 latest sticky posts that have a thumbnail. And I need to have accurate counting of the displayed posts. I've tried to exclude sticky posts without a thumbnail with meta_query, ...
1
vote
1answer
180 views

Show Sticky Post at the top but do not show again in the loop?

Regarding wordpress.org - sticky posts are displayed at the top but they also appear again in the loop. For the main loop on my homepage I want to display the sticky posts at the top BUT I don't ...
0
votes
2answers
108 views

Knowing if a post is sticky in the 'save_post' action. Where do I have to hook?

I'm using this plugin (FantasticElasticSearch) to index content when it's published. So far it was strightforward and an easy task but, now that I tried to index a flag saying if a post is sticky, I'm ...
1
vote
1answer
80 views

All sticky posts are returned in custom query

I have the following code: $recommended_args = array( 'post_type' => 'post', 'posts_per_page' => 3, 'post__in' => get_option('sticky_posts'), ...
1
vote
1answer
174 views

WP_Query doesn't get sticky post at the top, when used in a page template

I'm creating a theme in which I've created a page template called page_default-blog.php to be used for creating a blog page. In this file I have the following code: $paged = (get_query_var('page')) ? ...
1
vote
2answers
306 views

“Sticky” posts for each category (archive.php)

I need to have the ability to have Sticky posts for each category. The simplest way to do this appeared to be to just create two loops on the page. This is what I wrote: <?php //Custom "sticky" ...
1
vote
0answers
246 views

WP Query to have sticky posts first, with pagination and having a joint 'posts per page' arg with main loop

I am building a Wordpress site and have come to a bit of a wall while using a WP_Query, it started out quite simple but then sticky posts got thrown into the mix and it's becoming a bit harder to ...
2
votes
2answers
3k views

Adding Sticky functionality to Custom Post Type Archives

In WordPress, Custom Post Types do not have Sticky functionality as a core feature. It is possible, I'm sure, to create it in certain cases—and I'm working on a project that requires it for archive-{...
3
votes
1answer
271 views

Include sticky posts in 'Blog pages show at most' X number of posts?

I'm using the default Loop Code. I've set the 'Blog pages show at most' option in Settings > Reading to 11. In my home page -set to show Latest Posts- whenever I mark a post as 'Sticky' it's being ...
0
votes
2answers
538 views

Ignore sticky posts if post is not in meta query

I have such a wp query args: $args = array( 'post_type'=> 'myposttype', 'posts_per_page' => 10, 'meta_query' => array( 'relation' => 'AND', array('key' => 'routeFrom','value'...
0
votes
0answers
85 views

Sticky Post or Featured Post on every page

I'm using a sticky post to display some custom text on a blog homepage. It is the blue bar at the top. When I click on a blog post to read it (example), the sticky post goes away. Is there a way ...
0
votes
1answer
51 views

Sticky post of current viewing author?

How to show sticky post of current browsing author on author.php template? $sticky = get_option( 'sticky_posts' ); rsort( $sticky ); $sticky = array_slice( $sticky, 0, 5000 ); query_posts( array( '...
1
vote
1answer
477 views

How to make post sticky in the admin page?

i work with restaurant plugin that use custom post type. the question is, if it possible to select some post and make him sticky (always be in the top) in the admin? i need this because when you add ...
0
votes
2answers
94 views

Remove old sticky post on publish

I'm optimizing a WordPress site. For this, I have created a function that remove the old sticky posts. This function doesn't work correctly in some cases. Sometimes all sticky's are removed (so no ...
2
votes
1answer
551 views

Include Sticky Post in Page Posts Count?

I would like 7 posts showing on my homepage. I would like to be able to manually choose those posts by stickying them. Currently, I have my posts per page set to '7' in WP Admin. However, this does ...
0
votes
0answers
188 views

Theme code to display all sticky posts

I found this code to show one sticky post at the side of the page: <?php $sticky = get_option( 'sticky_posts' ); $the_query = new WP_Query( 'p=' . $sticky[0] ); while ($the_query->...
0
votes
1answer
404 views

3 Posts in Loop, Show Stickies First

Okay I am starting to wonder if it is even possible to do this! As I've found very little info on the matter online. This is a fresh WP install that I've been experimenting on so that I can work in a ...
3
votes
2answers
4k views

Wordpress 3.1 - How does one add sticky post capabilities to post types

In wordpress 3.1 they finally added the option of allowing posts belonging to a custom post type to be marked as "sticky"... what I can't figure out though is how to enable this so the admin menu ...
0
votes
1answer
48 views

Show image if a post is featured

I know that posts that are sticky show on top but I want to add an image to show that is featured is there any code I could use
0
votes
1answer
206 views

Loop for sticky posts

I used Justin Tadlock's tutorial on how to create a loop consisting only sticky posts. The code looked more or less like this: $sticky = get_option( 'sticky_posts' ); rsort( $sticky ); $sticky = ...
0
votes
1answer
409 views

How to Order Sticky Posts? [duplicate]

I've got a sticky post that i would like to move down to third position in between my regular posts on my site and for it to stay there permanently? I've already downloaded a few different sticky ...
0
votes
1answer
67 views

Check if parent post is sticky on attachment page?

I use this code on post template (single.php) to check if current post is sticky: <?php if ( is_sticky() ) echo 'Post is sticky.'; ?> But it is not working on attachment page template (image....