I am using this query;
<?php
$sticky = get_option( 'sticky_posts' ); // Get all sticky posts
rsort( $sticky ); // Sort the stickies, latest first
$sticky = array_slice( $sticky, 0, 1 ); // Number of stickies to show
query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1 ) ); // The query
if (have_posts() ) { while ( have_posts() ) : the_post(); ?>
<h2><a href="https://wordpress.stackexchange.com/questions/7384/<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<?php endwhile;?>
<?php } else { echo ""; }?>
Hope it works for you too.. 🙂
Related Posts:
- Apply styling only to first page sticky posts
- 3 Posts in Loop, Show Stickies First
- Move sticky posts down in main loop
- sticky post in custom loop
- Blog page Server error 500 with stick post loop in query.php
- Showing sticky posts with get_posts()
- Exclude duplicated $sticky post from combined loop content
- Exclude first post (sticky or not) from the loop using query_posts()
- Loop for sticky posts
- Custom Query with Sticky Posts
- Insert/sticky multiple posts in multiple positions
- Different style for first two (sticky) posts
- I make sticky post for my archive page for custom post type with ACF field and loop is not working
- How to display Yoast SEO meta description in archive template for each post instead of the_excerpt()? [closed]
- How to get Author ID outside the loop
- Why do themes rely on “The Loop”?
- How to place comments_template(); outside the loop?
- Endless loop with wp_insert_post and wp_update_post
- How do I prevent one of two multiple loops from repeating on a second page?
- Hook into the loop via a plugin, and output something after every X post?
- Two custom loops, pagination, offset
- How are both HTTP and HTTPS versions displaying?
- Access to Media Library
- Getting two wp_link_pages output
- post loop causes wp_users and wp_usermeta DB queries for each users
- How do you split multiple-column loop on category archive page?
- How to Loop within a Loop (Display Children and then Grandchildren)
- Run The Loop over array of post objects
- Enable infinite scroll on single.php [closed]
- How to loop through ALL pages?
- Does get_template_part pull data once in a loop?
- Get titles of all posts with current tags except current post
- Display posts from multiple user roles
- A loop with all articles with certain text strings in tags
- Prevent Headers from being sent
- How do I get row padding in a post feed?
- How can I create a legend (Key) like the one in the footer on WordPress StackExchange
- It is possible to encounter horrible bugs if I place a main loop that uses `query_posts` right above the main bbPress loop?
- How to show “teaser” posts on blog / archive pages, otherwise full posts
- Make blog page show 10 on first page, 9 on every other page
- Alter query using pre_get_posts() if meta_key is present
- Next Posts Prev Posts for Standard post format only
- Two loops on different pages do the same thing, but only one page works
- Posts active and expired in different loops
- Genesis multiple category custom loop 404s after first page
- Shortcode in posts called by ajax is not working
- Custom loops, sticky posts, and pagination nightmare
- Using Javascript for Looped Content
- Making a query to the DB using same parameters of loop
- Variable not being passed into WordPress loop
- Getting a custom field in the middle of a loop
- Pagination on Single Post
- Display Posts Only with Specific Tag
- Get author Meta for particular user inside the loop
- WP Loop. If featured image is a panorama (3:1 ratio) execute some code
- Trying to get property of non-object in shortocde
- Foreach displays from last to first
- value of metadata is null wrong use of if statement
- How to Loop with the final result formatted differently?
- Tags on page (not post) returns nothing – why? Improved clarified question!
- Include future posts in tags and in search
- Separate First Post Loop
- Category ID returns as ‘0’?
- make get_post work in the loop
- Show terms in archive page
- For Each +1 WordPress Loop
- Multiple loops for plugin
- Loops for cat links not looping for wordpress site
- Skip 5 latest post while paging?
- WordPress: query pages except remove one page
- get_post_meta printing empty fields, but it shouldn’t be
- Sort posts according to a numeric value entered with ACF
- wp_get_attachment_url not fetching URL?
- get the value for ALT is we check to see if an actual ALT value is set, if not we use the caption and if no caption is set we use the title
- how to add 4 post in one carousel slide
- How to get all multi-select user meta values and add them to an array?
- How to resolve a reload loop issue in the frontend when logged in to WordPress multi-site backend admin area
- Exclude Posts Using Meta Query and User Meta
- Is “the loop” a template tag?
- Excerpt isn’t working or am I missing something?
- Can I temporarily disable global $post?
- Shortcode for pulling specific Post Title outside loop when ID is passed in
- Show a list of user posts in the user admin page
- WordPress with woocommerce custom query
- Infinite Loop after Genesis Theme Upgrade
- Page gets displayed in post field
- Active class for my flexslider in WordPress
- WordPress loop only displays 5 articles max?
- get_template_part() to render single page Theme
- Can’t see custom field after the Loop [closed]
- Showing related posts (custom post type) outside of the loop
- Same Loop on Multiple Pages
- Paged homepage – requirements?
- Least Number of Loops to Create Custom Homepage?
- Multiple loops on index page with sticky post and pagination
- The Loop for my theme with static front page is not working
- WordPress loop: Display if posts exist
- Showing ads after posts in home page
- Prevent duplicating specific column from database table
- Use Base-URL with Query-Loop