• Home
  • Contact

Archive for Sticky

How To Display Just the Sticky Post on Front Page in WordPress

By Sridhar Katakam · Comments (8) · Tuesday, July 13th, 2010

Scenario

Settings -> Reading: Front page is set to display latest blog posts.

Blog pages show at most set to 1

When sticky post is the latest

In this case, only the sticky post is shown on the front page just like how we want.

When there are other published posts newer than the sticky post

In this case, 2 posts will be shown on the blog’s front page: the sticky post at the top and the latest post below it.

Solution

To fix this and have only the sticky post show up, add the following above the if/while statement that’s used to check the existence of posts (just above the loop) in index.php:

<?php
$sticky = get_option( 'sticky_posts' );
query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1, 'orderby' => ID, 'showposts' => 2 ) );
?>

Screenshot

Source: http://wptricks.net/display-a-sticky-post-only/

Comments (8)
Categories : WordPress
Tags : Sticky

Sridhar Katakam

My name is Sridhar Katakam. I work at iThemes as support moderator and my job involves helping people build awesome sites with WordPress and iThemes Builder in particular.

Recent Posts

  • 10,000 Posts in iThemes Builder Forum and counting…
  • Natural Vision Guides Niche Review Template Now Available in WordPress
  • Public Records Niche Review Template Now Available in WordPress Format
  • Tinnitus Remedies Review Template Now Available in WordPress Format
  • Personal Dental Care Site
  • Keyconfig in Firefox
  • Independence Day Celebration Photos
  • How To Display Just the Sticky Post on Front Page in WordPress
  • Builder Child Theme – White
  • Two Simple Sites in Builder
  • WordPress 3.0
  • Wonder La Trip
  • Skin Care Niche Review Template Now Available in WordPress Format
  • PreForeclosure Niche Review Template Now Available in WordPress Format
  • Arthritis Niche Review Template Now Available in WordPress Format

Twitter Updates

Recommended Resources

  • Digital Access Pass
  • DLGuard
  • HostGator
  • iThemes
  • StudioPress
Sridhar Katakam's Blog runs on Builder by iThemes
Copyright © 2012 All Rights Reserved