• So I’ve searched answers everywhere and can’t find the exact advice I need.
    How do I just display my Sticky post on the home page? Im using the 2010 weaver theme if that helps at all..
    I’ve tried altering the ‘reading’ section to display one, as people advised, but then one one post displays when listing the categories as well, and that’s no good.
    I’m not good with code or anything of the sort, so if you advise me that way, please take baby steps and walk me through it!

    I’m good with plug-ins lol

    thanks in advance

Viewing 9 replies - 1 through 9 (of 9 total)
  • Put the following lines of code in loop.php, just ahead of the while ( have_posts() ) line, like this:

    <?php if (is_front_page()) {
       $stickies = get_option('sticky_posts');
       if ($stickies) {
          query_posts(array_merge($wp_query->query,
                              array('post__in' => $stickies)));
       }
    }
    ?>
    <?php while ( have_posts() ) : the_post(); ?>
    Thread Starter userme

    (@userme)

    Thanks for the reply!
    But I don’t see loop.php
    I installed Platform pro (dont ever do that) so maybe that changed things?
    Wouldnt happen to know how to get rid of it and back to normal, wouldja?

    ??
    thnx..

    Be sure to back up your theme before you try this!

    Go to Admin->Appearance->Editor. Find loop.php in the right panel and click it.

    Scroll down to the correct place in the code and enter the lines from above. Click ‘Update File’.

    Depending on which theme you’re using, there might not be a loop.php file. If you can’t find loop.php in the section vtxyzzy mentioned, try looking at index.php and see if the loop appears in that file. Again, you’d be looking for code similar to if( have_posts() ) : while( have_posts() ) : the_post();

    Im using the 2010 weaver theme if that helps at all..

    Thread Starter userme

    (@userme)

    How do you people know all this? Was it something you were born with? i think it has to be.. and I think I missed that gene.
    Been trying to teach myself everything and it’s just not clicking!

    :p

    I did find the loop.php thank you, thank you..
    but alas..

    after trying as many variations of what you told me to do as possible in hopes of not having to come back and ask again.. I can’t make it work!!
    It says parse error something something whenever I try to put it in.

    I found the line:

    ?>

    <?php while ( have_posts() ) : the_post(); ?>

    is that right? It’s the only ‘while have posts’ I could see..

    Thank you again and again.. and again..

    Sorry, I should have included a bit more of the code. Make it look like this:

    * archive page, a search page, etc., allowing for small differences
    	 * in the loop on each template without actually duplicating
    	 * the rest of the loop that is shared.
    	 *
    	 * Without further ado, the loop:
    	 */
    	?>
    <?php if (is_front_page()) {
       $stickies = get_option('sticky_posts');
       if ($stickies) {
          query_posts(array_merge($wp_query->query,
                              array('post__in' => $stickies)));
       }
    }
    ?>
    <?php while ( have_posts() ) : the_post(); ?>

    And, after 38 years of programming, I am supposed to know a few things!

    Thread Starter userme

    (@userme)

    oh yah.. you’re amazing.

    38yrs? I don’t feel so slow anymore, thank you.
    I’m going on 3 weeks!

    Three weeks is just a drop in the bucket. ?? I haven’t been coding for 38 years, but I have been working with PHP for about 10 years and working with WordPress for about 3 years.

    Keep at it, and you’ll start to learn. The beautiful thing about PHP and WordPress is that the documentation for both is completely free and available online; so you can learn a lot just by searching the docs. ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘how to show only sticky on homepage?’ is closed to new replies.