What is a sticky post in wordpress

New Page

How to Make Sticky Posts in WordPress

Last updated April 7, 2019 by Editorial Team | Reader Disclosure Disclosure : Our content is reader approved. This means that if you click on some of our links, we may earn a commission. Find out how WPBeginner is funded, why it matters, and how you can support us.

Shares 34 Share Tweeter Share Facebook Messenger WhatsApp E-mail

Looking for a way to display your most important posts at the top of your blog page so people can see them first?

WordPress displays your most recent posts first by default. As you add content, your previous posts are deleted and possibly moved to the archive.

What if you wanted to display your featured articles on the front page for longer?

This is where the sticky posts feature of WordPress comes in handy.

A sticky post is a post that stays at the top of your blog page. Unlike your regular posts, it stays on the front page of your blog until you remove your sticky option.

In this article, we will show you how to easily create sticky posts in WordPress in just 2 steps.

How to Make Your WordPress Posts Sticky How to Make Your WordPress Posts Sticky

When to use a WordPress post-it?

A sticky post is primarily useful for highlighting important content on your blog. This allows you to present your best articles on the front page of your blog, regardless of their publication date.

There are mainly 2 types of content that you can pin to your blog’s homepage.

1. The best content (pillar articles) on your blog

Mainstay articles are the most important content on your website. This includes in-depth articles, comprehensive guides, and their most popular posts.

They are the best way to introduce new users to your blog, generate leads and increase page views. You want to highlight them on your website to ensure that new users can find these items.

For example, you can have an entire article that covers a specific topic in great detail. Such an article will be very useful to your users and you may want to place it on the top.

2. Critical content for temporal relevance

Another type of posts you may want to make sticky are time-relevant posts like product updates, announcements, giveaways, etc.

Suppose you announced a major product update through your blog, and then you want your users to see it as soon as possible. Likewise, if you’re hosting a giveaway for a month, you’ll want everyone to see it before it expires.

After their temporary relevance expires, you can replace them with new sticky posts.

That said, let’s see how to easily make your posts sticky in WordPress.

Make WordPress Posts Sticky in 2 Steps

WordPress comes with a function incorporated for each publication on the main page. Todos los themes de WordPress que cumplen con los estándares admiten esta función y resaltarán la publication fija en la main página or en la página del blog.

Primero, debe editar la publicación que desea hacer fija o crear una nueva.

On the post edit screen, look towards the right-hand sidebar where you will see your document settings. Click on ‘Status and Visibility’ option first.

Status and visibility option in WordPress Post Editor Status and visibility option in WordPress Post Editor

Now you will see a checkbox option for ‘Stick to the Front Page.’ Simply check the box to make the post sticky and then save or publish your post.

Stick to Homepage Option in WordPress Stick to Homepage Option in WordPress

That’s it! Your post will now stick to your blog’s front page until you remove the check.

If you want to make an older post sticky, follow the same steps and just click save.

You can also make older posts sticky with the Quick Edit feature.

Simply go to the Posts » All Posts page from your dashboard and search for the respective post title. Next, you need to click the ‘Quick Edit’ option below it.

Quick Edit WordPress Post Quick Edit WordPress Post

After that, you will see the quick edit options including a sticky post checkbox at the bottom on the right side. You need to check the box and click the ‘Update’ button below.

Make This Post Sticky Option in WordPress Make This Post Sticky Option in WordPress

You can also apply this on your unpublished drafts to make them sticky once they are published.

We hope this article helped you to learn how to make sticky posts in WordPress easily. You may also want to see our guide on 6 cool things you can do with your WordPress and how to show your latest sticky posts.

If you liked this article, please subscribe to our YouTube channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Shares 34 Share Tweeter Share Facebook Messenger WhatsApp E-mail

Skip to content

  • connection
  • Register

WordPress.org

  • New
  • Download and extend
    • Get WordPress
    • Themes
    • patterns
    • plugins
    • Openverse
    • Mobile
    • accommodation
  • Learn
    • Learn WordPress
    • Support
    • Forums
    • wordpress.tv
    • developers
  • Community
    • BrandWordPress
    • WordCamp
    • Met
    • Photo Directory
    • Job board
    • Five for the future
  • About
    • About WordPress
    • showcase
    • Gutenberg
    • Company
  • Get WordPress

Chercher

Obtenir WordPress

Menu

Ressources pour les développeurs

Chapitres

  • Commencer

    • Qui devrait lire ce manuel ?
    • Qu’est-ce qu’un thème ?
    • Licence WordPress et GPL
    • Mise en place d’un environnement de développement
    • Exemples de développement de thème
  • Principes de base du thème

    • Fonctions thématiques
    • Fichiers modèles
    • Feuille de style principale (style.css)
    • Types de publication
    • Organisation des fichiers de thème
    • Hiérarchie des modèles
    • Including CSS & JavaScript
    • Categories, Tags, & Custom Taxonomies
    • Tools & Resources
  • Block themes

    • Block theme setup
    • Templates and template parts
    • Theme.json
    • Converting a classic theme to a block theme

      • Converting customizer settings to block patterns
    • Creating new themes using the Site Editor
    • Internationalization
    • Accessibility
  • Classic themes

    • Your First Theme
    • Linking Theme Files & Directories
    • The Loop
    • Template Files Section

      • Post Templates
      • Page Templates
      • Attachment Template Files
      • Custom Post Type Template Files
      • Partial and Miscellaneous Template Files

        • Comment Template
      • Taxonomy Templates
      • 404 Pages
    • Conditional Tags
    • Template Tags
    • Theme Functionality

      • Core-Supported Features

        • Administration Menus
        • Custom Headers
        • Custom Logo
        • Post Formats
        • Sticky Posts
      • Sidebars
      • Widgets
      • Navigation Menus
      • Pagination
      • Media

        • Audio
        • Images
        • Galleries
        • Video
      • Featured Images & Post Thumbnails
      • Internationalization
      • Localization
      • Accessibility
    • Theme Options – The Customizer API

      • Customizer Objects
      • Tools for Improved User Experience
      • The Customizer JavaScript API
      • JavaScript/Underscore.js-Rendered Custom Controls
      • Advanced Usage
  • Theme Security

    • Data Sanitization/Escaping
    • Data Validation
    • Using Nonces
    • Common Vulnerabilities
  • Theme Privacy
  • Advanced Theme Topics

    • Child Themes
    • UI Best Practices
    • JavaScript Best Practices
    • Theme Testing
    • Validating Your Theme
    • Plugin API Hooks
    • Block patterns
  • Releasing Your Theme

    • Required Theme Files
    • Testing
    • Theme Review Guidelines
    • Writing Documentation
    • Submitting Your Theme to WordPress.org
    • Updating Your Theme
  • References

    • List of Template Tags
    • List of Conditional Tags
  • Credits
  • Feedback

Browse: Home / Theme Handbook / Theme Functionality / Sticky Posts

Sticky Posts

Topics

  • How to stick a post
  • Display Sticky Posts
    • Show Sticky Posts
    • Don’t Show Sticky Posts
  • Style Sticky Posts

Un message collant est le message qui sera placé en haut de la page d’accueil des messages. Cette fonctionnalité n’est disponible que pour le type de publication intégré et non pour les types de publication personnalisés.

Comment coller un poteau

  1. Accédez à l’écran d’administration > Messages > Ajouter un nouveau ou Modifier
  2. In the right menu, click on the Edit link of the Visibility option in the Publish group
  3. Click on the option Paste this message on the homepage

sticked_post

Top ↑

Show sticky messages

Top ↑

Show sticky messages

Show only the first sticky post. At least one message must be designated as a “sticky message”, otherwise the loop will display all messages:

$sticky = get_option(‘sticky_posts’); $query = new WP_Query(‘p=’.$sticky[0]);

Show only the first sticky message, if none returns the last posted message:

$args = array( ‘posts_per_page’ => 1, ‘post__in’ => get_option( ‘sticky_posts’ ), ​​ignore_sticky_posts’ => 1 ); $query = new WP_Query( $arguments);

Show only the first pinned message, if none returns anything:

$sticky = get_option(‘sticky_posts’); $arguments = array( ‘posts_per_page’ => 1, ‘post__in’ => $sticky, ‘ignore_sticky_posts’ => 1 ); $query = new WP_Query( $arguments); if ( isset ($sticky[0] ) ) { // insert your stuff here… }

Top ↑

Do not show sticky messages

Exclude all persistent messages from the query:

$query = new WP_Query( array( ‘post__not_in’ => get_option( ‘sticky_posts’ ) ) );

Exclude persistent posts from a category. Resend ALL posts in the category, but do not show sticky posts at the top. ‘Sticky posts’ will always be displayed in their natural position (e.g. by date):

$query = new WP_Query(‘ignore_sticky_posts=1&posts_per_page=3&cat=6’ );

Exclude persistent posts from a category. Return posts to the category, but exclude pinned posts altogether and respect the pagination rules:

$paginated = get_query_var(‘paginated’)? get_query_var(‘paged’): 1; $sticky = get_option(‘sticky_posts’); $arguments = array( ‘cat’ => 3, ‘ignore_sticky_posts’ => 1, ‘post__not_in’ => $sticky, ‘paged’ => $paged ); $query = new WP_Query( $arguments);

Note: Use get_query_var( ‘page’ ) if you want this query to work in a page template that you have set as a static homepage.

<?php /* Get all sticky posts */ $sticky = get_option(‘sticky_posts’); /* Sort sticky posts, newest on top */ rsort( $sticker ); /* Get the top 5 featured articles */ $sticky = array_slice( $sticky, 0, 5 ); /* Query sticky posts */ $query = new WP_Query( array( ‘post__in’ => $sticky, ‘ignore_sticky_posts’ => 1 ) ); ?>

Top ↑

Style Sticky Posts

To help theme authors do simpler styling, post_class() function is used to add class=”…” to DIV, just add:

<div id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>

The post_class() generates the class=”whatever” chunk for that div. This includes several different value classes: post, hentry (for hAtom microformat pages), category-X (where X is the slug for each category the post is in), and tag-X (similar, but with tags ) . It also adds a “sticker” for posts marked as Sticky Posts.

.sticky { color:red; }

Note: The “sticky” class is only added for sticky posts on the first page of the homepage (is_home() is true and is_paged() is false)

 

Manual navigation

← Post Format Sidebars →

  • About
  • New
  • accommodation
  • make a donation
  • Support
  • developers
  • To be involved
  • Learn
  • showcase
  • plugins
  • Themes
  • patterns
  • WordCamp
  • wordpress.tv
  • buddy press
  • bbPress
  • wordpress.com
  • Mast
  • privacy
  • public code
  • Visit our Facebook page
  • Visit our Twitter account
  • Visit our Instagram account
  • Visit our LinkedIn account

The code is poetry g

Notice

g


Video What is a sticky post in wordpress

Related Posts

Free chat room code for my website

Contents1 How to set up a free chat room on the website.2 3 comentarios2.1 Trackbacks/Pingbacks2.2 Submit a Comment Cancel reply3 How to Create a Chat Room Website…

Background image full screen css

Contents1 Cómo – Full Page Image1.1 Example1.2 Example2 CSS background image tamaño tutorial: how to codify a complete page background image3 Perfect Full Page Background Image3.1 Méthode CSS géniale,…

WordPress leverage browser caching

Contents1 Aproveche el almacenamiento in hidden del navegador1.1 Will it works for my website?1.2 Where are plugin options1.3 Some JavaScript files still display under Leverage Browser Caching1.4…

WordPress post to facebook page

Contents1 How to Automatically Post to Facebook from WordPress1.1 Download Now: How to Launch a WordPress Website [Free Guide + Checklist]1.2 1. Create an IFTTT account.1.3 2….

Download images from wordpress media library

Contents1 How to export your WordPress media library1.1 Download maintenant : How to launch a WordPress website [Free Guide + Checklist]1.2 How to export your WordPress media…

WordPress single post template

Contents1 How to Create Custom Unique Post Templates in WordPress2 Post Template Files2.1 author.php2.2 Fecha.php3 Handbook navigation4 How to Create Custom Single Post Templates in WordPress5 Video…