WordPress.org

Ready to get started?Download WordPress

Forums

Sticky Custom Post Types
Sticky posts not being output first (1 post)

  1. David Hunt
    Member
    Posted 1 year ago #

    Hi,

    This is a lovely plugin and it's working very well for me, except for one thing: my sticky custom posts are not being pulled out of the flow and placed first! They are just appearing in the regular order of the posts, as if they weren't sticky at all.

    This is a simplified version of my code:

    <?php // get the most recent posts
    	$lim = get_option('posts_per_page');
    	query_posts('post_type=custom_post_type_events&post_status=publish&posts_per_page=$lim&paged='.get_query_var('paged'));
    	if( have_posts() ): ?>
    		<section id="itemSummaryList">
    		<?php while( $wp_query->have_posts() ): $wp_query->the_post();
    			<article <?php post_class() ?> id="post-<?php the_ID(); ?>">
    				<h2 class="entry-title"><?php if (is_sticky()) _e('Featured Event: ','mylang'); the_title(); ?></h2>
    				<div class="entry-content">
    					<?php the_excerpt(); ?>
    				</div>
    			</article>
    			<?php endwhile; ?>
    		</section>
    	<?php endif; ?>

    The same code works exactly as expected if I set post_type=post in the query. Can anyone see a reason why it would not work for the custom post type? (And yes, there are sticky custom posts set! The above code outputs "Featured Event: " before the title of any sticky posts, so I can see that the sticky flag is being picked up.)

    http://wordpress.org/extend/plugins/sticky-custom-post-types/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic