WordPress saves sticky posts inside the option named sticky_posts
. You can retrieve them via get_option('sticky_posts')
.
With that knowledge it is possible to change the query to only query for sticky posts, you usually do so via the pre_get_posts
hook.
add_action('pre_get_posts', 'WPSE_home_only_stickies');
function WPSE_home_only_stickies($query) {
// only run for homepage & main query
if ($query->is_home() && $query->is_main_query()) {
$sticky_posts = get_option('sticky_posts');
$query->set('post__in', $sticky_posts);
}
}
Related Posts:
- How to make my front page display only the most recent sticky post, plus usual widgets?
- Programmatically set page_on_front
- How to add “Stick this post to the front page” to front end?
- How do I show sticky posts on a static front page that also contains content?
- How do I set the front page programmatically?
- Custom background for the index page only?
- Load front-page.php from subfolder
- Can you select a post as the front page or only pages?
- Can’t edit front page of website [closed]
- How to block access to blog-page for users not logged in?
- Pagination not Working on only Front page on latest verson of WordPress
- Do I need an empty page for a different blog page?
- Showing option when page is frontpage
- Is it possible for homepage in Twentyseventeen theme to look like a standard page?
- Include sticky posts on the static page front page
- WordPress site front page fails to load in IE
- Home/front page won’t display content after a form is submitted
- how to create a static front page for my blog in wordpress
- Exclude all sticky posts front page twenty twelve
- Home link in the homepage of my wordpress does not show my blog posts
- WordPress, how to figure out how to edit front page
- How to set a static html front page
- Why: sticky front page code, shows latest non-sticky on logged-in front page
- NON Static-Front Page
- Front Page Settings
- What code controls the animation for the front-page header in TwentySeventeen
- Setting index.php as a static home page without posts?
- Implement a slideshow-like frontpage with text overlays
- Showing “best posts” in front page
- Pull in content from page defined as static front page
- Excluding front_page from is page condition
- Why does my site show the correct front-page when you arrive at the site, but not when you click ‘home’?
- Change Front Page Word Press 4.1
- custom change in front page [closed]
- Remove edit post link from static front page
- WordPress certain directories not connected
- Different front page for logged in and logged out user but the same URL in WordPress
- Homepage not working after setting as frontpage
- Hiding New Posts on Front Page
- change header height on 2017 theme for logged in users
- How to connect front-page.php to page in admin panel?
- Can I have two websites with one front page
- I created a new home page and set it as the home page in the reading section, but I get an error when typing in the home page url
- Categories with post from child categories on front page
- Static front page – going against the grain
- When Front page and Posts page are specified is it possible to just have front-page.php as the home page?
- Custom background for the index page only?
- No posts on front page
- Front page welcome message area
- Static front page as parent of with child pages?
- How did WordPress link an empty page at dashboard to an actual php file?
- When to use is_home() vs is_front_page()?
- Sticky Posts exceed posts per page limit
- Using pre_get_posts on true pages and static front pages
- why ignore_sticky_posts in sticky post query
- How can I create a “Read More” link using the_excerpt() on a static front page?
- is_front_page() malfunction?
- How do I fetch the static front page using the REST API?
- Code to make a post sticky
- Ways to have multiple front-page.php templates that can be swapped out?
- WP_Query: Why is sticky post not first item in loop?
- is_front_page only works in theme file, and does not work in functions.php
- Query *only* sticky posts
- What is the correct method for determining ‘is_front_page’ when using filters such as ‘pre_get_posts’ and ‘posts_where’?
- Exclude sticky post from main query?
- Show Sticky Posts in Category Archive
- Set sticky posts schedule (Automatic)
- Category page doesn’t use category.php, instead it redirects to homepage
- Show all sticky posts, WITH pagination
- Sticky Posts & Posts Per Page [closed]
- How to put custom post types on front page
- Ensuring sticky posts are retrieved first (without using two queries)?
- How to prevent the default home rewrite to a static page
- Facebook comments box on front page
- Filter front page posts by category
- Highlight a Featured Post?
- How does WordPress decide what template to use as frontpage
- Custom query_var causes displaying posts archive on front page
- Limiting query_posts to 1, regardless of sticky post?
- How to make “sticky” pages (and query by them)
- Add a single featured post to all pages?
- Static page homepage not showing the_content
- Using categories & “stickyness” together
- Sticky posts on home page, search, tag and archives without plugin
- How to retrieve sticky post in raw sql?
- WordPress 3.1 – How does one add sticky post capabilities to post types
- front-page.php stylesheet
- Unable to load static front page on home url
- How to set a custom post type post as static front page?
- Display only the most recent sticky post, display other posts in chronological order
- Disable sticky posts feature
- Apply styling only to first page sticky posts
- index.php not loading in main folder of wordpress
- Include sticky posts in ‘Blog pages show at most’ X number of posts?
- Include Sticky Post in Page Posts Count?
- How to create custom home page via plugin?
- Add Adsense code in index.php
- wp_query for the first sticky, then display the rest of the posts excluding the first sticky
- Adding Sticky functionality to Custom Post Type Archives
- wordpress Static Page pagination