Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Center area post/pages »

Limit number of sticky posts on home page


  #1  
Old Jul 19, 2010, 02:30 PM
True
 
11 posts · Jul 2010
Cape Town, South Africa
Hi there,

I am busy working on my site and I want to be able to limit the amount of sticky posts shown on the homepage.

In other words, on the homepage, I want there to be the 4 most sticky posts and then the rest of the posts in date order below them. I want this only on the homepage (on on other pages the normal posts in date order must be shown).

I know I probably need to edit the loop. Can you please advise? This is what I currently have in the loop:

PHP Code:
<?php /* For SINGLE post pages if activated at ATO -> Next/Previous Navigation: */
bfa_next_previous_post_links('Top'); ?>

<?php /* Post Container starts here */
if ( function_exists('post_class') ) { ?>
<div <?php if ( is_page() ) { post_class('post'); } else { post_class("$odd_or_even"); } ?> id="post-<?php the_ID(); ?>">
<?php } else { ?>
<div class="<?php echo ( is_page() ? 'page ' '' ) . $odd_or_even ' post" id="post-'the_ID(); ?>">
<?php ?>

<?php bfa_post_kicker('<div class="post-kicker">','</div>'); ?>

<?php bfa_post_headline('<div class="post-headline">','</div>'); ?>

<?php bfa_post_byline('<div class="post-byline">','</div>'); ?>

<?php bfa_post_bodycopy('<div class="post-bodycopy clearfix">','</div>'); ?>

<?php bfa_post_pagination('<p class="post-pagination"><strong>'.__('Pages:','atahualpa').'</strong>','</p>'); ?>

<?php bfa_post_footer('<div class="post-footer">','</div>'); ?>

</div><!-- / Post -->
Thanks for your time
  #2  
Old Jul 19, 2010, 03:15 PM
lmilesw's Avatar
lmilesw
 
10,176 posts · Jul 2009
Central New York State USA
You might want to look at AStickyPostOrderER plugin as opposed to fiddling with code.
__________________
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.
  #3  
Old Jul 19, 2010, 03:27 PM
True
 
11 posts · Jul 2010
Cape Town, South Africa
I have given that plugin a try - but its way more than I need. In fact, its just an extra step and I would prefer the loop code to do it automatically.

All I want to do is limit the number of sticky posts shown.

This site shows the code to insert: http://justintadlock.com/archives/20...s-in-wordpress

However, Atahualpa uses a loop code that seems to be different from other loops that I have seen.

Can anyone else help? I will be so thankful!
  #4  
Old Jul 19, 2010, 03:41 PM
lmilesw's Avatar
lmilesw
 
10,176 posts · Jul 2009
Central New York State USA
Have you tried sticking that code in the "ATO>Style & edit CENTER COLUMN>Content ABOVE the LOOP" box? I just did that and it worked pretty sweet. Nice catch on that code. That's a keeper.
__________________
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.
  #5  
Old Jul 19, 2010, 03:46 PM
lmilesw's Avatar
lmilesw
 
10,176 posts · Jul 2009
Central New York State USA
I just discovered that the stickies are not limited to the Home page. I will have to test a bit.
__________________
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.
  #6  
Old Jul 19, 2010, 03:58 PM
lmilesw's Avatar
lmilesw
 
10,176 posts · Jul 2009
Central New York State USA
This works. I just put at the bottom of the ATO>Style & edit CENTER COLUMN>Content ABOVE the LOOP" box
HTML Code:
<?php if ( is_front_page() ) { ?>
<?php
    /* Get all sticky posts */
    $sticky = get_option( 'sticky_posts' );

    /* Sort the stickies with the newest ones at the top */
    rsort( $sticky );

    /* Get the 2 newest stickies (change 2 for a different number) */
    $sticky = array_slice( $sticky, 0, 2 );

    /* Query sticky posts */
    query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1 ) );
?>
<?php } ?>
__________________
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.
  #7  
Old Jul 19, 2010, 05:45 PM
True
 
11 posts · Jul 2010
Cape Town, South Africa
lmilesw, I did that exactly as you said and it works. However, it shows just the sticky posts and thats it.
What I would love now is for the rest of the blog posts to show under these sticky posts.

Any ideas?
  #8  
Old Jul 19, 2010, 07:02 PM
lmilesw's Avatar
lmilesw
 
10,176 posts · Jul 2009
Central New York State USA
I see what you mean and I have been fiddling with this code for a couple of hours now. I did find that the following works as the previous but has a bit less code.
HTML Code:
<?php    if ( is_front_page ){
    /* Get all sticky posts */
    $sticky = get_option( 'sticky_posts' );

    /* Sort the stickies with the newest ones at the top */
    rsort( $sticky );

    /* Get the 2 newest stickies (change 2 for a different number) */
    $sticky = array_slice( $sticky, 0, 2 );

    /* Query sticky posts */
    query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1 ) ); }
?>
I put this in the "ABOVE the LOOP" box but cannot figure out how to get it to continue with the regular posts.

Are there any coders out there who can help?
__________________
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.

Bookmarks

Tags
limit, loop, sticky, sticky-post



Similar Threads
Thread Thread Starter Forum Replies Last Post
Limit number of posts on home page? anishinaboy Page & Category Menu Bars 2 Jul 11, 2010 01:34 PM
How to limit number of posts displayed on home page rickinesc Atahualpa 3 Wordpress theme 2 Nov 14, 2009 03:14 PM
Limit number of posts when only showing one category bodger Atahualpa 3 Wordpress theme 3 Oct 8, 2009 12:27 PM
Limit the number of posts per page mcgiver058 Atahualpa 3 Wordpress theme 1 Aug 20, 2009 10:01 PM
Limit the number of Posts on Home Page coaxkid Post-Kicker, -Byline & -Footer 4 Apr 12, 2009 07:01 PM


All times are GMT -6. The time now is 12:35 PM.


Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.