WordPress.org

Ready to get started?Download WordPress

Forums

Problem with sticky post (3 posts)

  1. FxB
    Member
    Posted 4 years ago #

    Hello, i'm using this code for my blog page but it only shows my sticky post, the other ones doesn't show. Does someone have an idea?
    Thanks in advance

    <!--stickypost-->
        <?php
        /* Get all sticky posts */
        $sticky = get_option( 'sticky_posts' );
    
        /* Sort the stickies with the newest ones at the top */
        rsort( $sticky );
    
        /* Get the 5 newest stickies (change 5 for a different number) */
        $sticky = array_slice( $sticky, 0, 5 );
    
        /* Query sticky posts */
        query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1 ) );
        ?>
    
    <!--endstickypost-->
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    		<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    
    			<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    				<?php include (TEMPLATEPATH . '/inc/meta.php' ); ?>
    					<div class="entry">
                  <?php the_post_thumbnail(); ?>
    				<?php the_content(); ?>
    			</div><!--end entry-->
    
    			<div class="postmetadata">
    				<?php the_tags('Tags: ', ', ', '<br />'); ?>
    				Post&eacute; dans <?php the_category(', ') ?> |
    				<?php /*?><?php comments_popup_link('Pas de Commentaires »', '1 Comment »', '% Comments »'); ?><?php */?>
    			</div><!--endpostmedadata-->
    
    		</div><!--end post-->
  2. esmi
    Theme Diva & Forum Moderator
    Posted 4 years ago #

    Have you tried removing:

    <!--stickypost-->
        <?php
        /* Get all sticky posts */
        $sticky = get_option( 'sticky_posts' );
    
        /* Sort the stickies with the newest ones at the top */
        rsort( $sticky );
    
        /* Get the 5 newest stickies (change 5 for a different number) */
        $sticky = array_slice( $sticky, 0, 5 );
    
        /* Query sticky posts */
        query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1 ) );
        ?>
    
    <!--endstickypost-->
  3. FxB
    Member
    Posted 4 years ago #

    Yes and it works find but i can't control the number of sticky posts (except in the wordpress admin), they all show up. The problem comes from the fact that my loop seems not to be read my i use my stickypost php code

Topic Closed

This topic has been closed to new replies.

About this Topic