SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2007
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wordpress: top "sticky" post appears twice on blog

    I've made an important post on my WP blog as a "sticky" so that it always appears first at the top of the home-page.

    Small annoyance... that same post also appears again in the order that I posted it. One workaround is to make the date older than all other posts so that it's second appearance is on the last (earliest) page.

    Still, I'd like for it to appear only once, in it's top sticky position... any suggestions? Thanks.

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    See the "To exclude all sticky posts..." example for using query_posts() to change what posts appear in a list:
    http://codex.wordpress.org/Template_...ost_Parameters

  3. #3
    SitePoint Zealot jimmy85's Avatar
    Join Date
    Aug 2009
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lol weird, I just noticed this now too. It does appear twice, one on top, as a sticky, and then in it's natural order as per sorting or display method.

    It also appears with a different background, like highlighted, in its natural order.

  4. #4
    SitePoint Zealot
    Join Date
    Nov 2007
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had long forgotten about this, but wanted to try it. On that page that Dan mentions, at the top section that says "Usage" it shows to place the query_posts function on the Main Index Template (index.php) presumably between the first <?php tag and //The Loop
    if ( have_posts() ) : while ( have_posts() ) : the_post();


    The code to exclude all sticky posts from the query is:
    query_posts(array("post__not_in" =>get_option("sticky_posts")));


    Ok, but the index.php I have for the current WP 2.9.2 isn't quite exactly like that one example, so I tried:

    <?php /* The LOOP starts here. Do this for all posts: */
    query_posts(array("post__not_in" =>get_option("sticky_posts")));
    while (have_posts()) : the_post(); $bfa_ata['postcount']++; ?>


    Is that correct? It worked with the example for "return just the first sticky post or nothing" but when I try it with the code for "exclude all sticky posts from the query" ...the result is that if I go to "Older entries" I just keep getting the same first page (but with an incrementing page number each time)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •