Return to Snippet

Revision: 22510
at January 13, 2010 15:54 by gd6d


Initial Code
<?php
    $sticky = get_option( ’sticky_posts’ );
    query_posts( array( ‘post__in’ => $sticky, ‘caller_get_posts’ => 1, ‘orderby’ => ID, ’showposts’ => 2 ) );
    ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <a href=”<?php the_permalink(); ?>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”>
    <?php endwhile;?>

    <?php endif; ?>


    <?php $sticky = get_option(’sticky_posts’) ;

    $post_to_exclude[] = $sticky[0];

    $args=array(
    ‘caller_get_posts’=>1,
    ’showposts’=>2,
    ‘post__not_in’=> $post_to_exclude,
    );

    query_posts($args); ?>

    <h2><a href=”<?php the_permalink() ?>”><?php the_title(); ?></a> </h2>

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

    <?php endwhile;?>

Initial URL
http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/

Initial Description

                                

Initial Title
Display sticky post and exclude it from recent posts list in WordPress

Initial Tags
wordpress

Initial Language
PHP