Sticky posts are important. They stay on top of your post list. Users see them first. This is useful. It highlights important posts.
WordPress has a feature for sticky posts. But, it works only for regular posts. What if you have custom post types? You need to do a bit more work. Don’t worry. It is simple. I will show you how.
What Are Custom Post Types?
WordPress has different types of content. These are called post types. The default ones are posts and pages. But, you can create your own. These are custom post types. For example, you can have a post type for products. Or for events. Custom post types make your site more flexible.

Credit: www.advancedcustomfields.com
Why Use Sticky Posts?
Sticky posts are very helpful. They keep important posts at the top. This is good for announcements. Or for special offers. Users see them first. It helps in getting more attention.
Steps to Add Sticky Posts in Custom Post Types
Now, let’s add sticky posts. Follow these simple steps. You need to add some code to your theme files. It’s easy. Just be careful. Here’s how:
Step 1: Add Support For Sticky Posts
First, tell WordPress that your custom post type supports sticky posts. Open your theme’s functions.php
file. Add this code:
function add_sticky_support() {
add_post_type_support( 'your_custom_post_type', 'sticky' );
}
add_action( 'init', 'add_sticky_support' );
Replace your_custom_post_type
with your actual post type. This code tells WordPress to allow sticky posts for your custom post type.
Step 2: Modify The Query
Next, modify the query. This makes sure sticky posts show up at the top. Open the functions.php
file again. Add this code:
function modify_custom_post_type_query( $query ) {
if ( $query->is_main_query() && !is_admin() && $query->is_post_type_archive( 'your_custom_post_type' ) ) {
$query->set( 'post__in', get_option( 'sticky_posts' ) );
$query->set( 'ignore_sticky_posts', 1 );
}
}
add_action( 'pre_get_posts', 'modify_custom_post_type_query' );
This code changes the query for your custom post type archive. It makes sure sticky posts appear first.
Step 3: Style Your Sticky Posts
Finally, style your sticky posts. This makes them stand out. Open your theme’s stylesheet (style.css
). Add this code:
.sticky {
background-color: #f0f0f0;
border: 2px solid #ccc;
}
This code gives sticky posts a different background color. And a border. You can change the styles as you like.
Frequently Asked Questions
What Is A Sticky Post In WordPress?
A sticky post stays at the top of your blog archive.
Why Use Sticky Posts For Custom Post Types?
Sticky posts highlight important content in custom post archives.
How To Make A Post Sticky In WordPress?
Edit the post, then check “Stick this post to the front page. “
Can Sticky Posts Work With Custom Post Types?
Yes, with added code or plugins, sticky posts can work.
Conclusion
That’s it! You have added sticky posts to your custom post type archives. Now, important posts will always stay on top. This helps users see key posts first. It is a simple way to improve your site.
Remember, always backup your theme files before making changes. This keeps your site safe. Happy coding!

Credit: www.wpbeginner.com
Summary
Here is a quick summary:
- Sticky posts stay at the top of the post list.
- Custom post types allow more content flexibility.
- Add support for sticky posts in
functions.php
. - Modify the query to show sticky posts first.
- Style your sticky posts for better visibility.
Follow these steps. Your custom post type archives will be better. Users will see important posts first. It’s a simple and effective way to enhance your site.