Exclude sticky post from navigation in single.php
-
Sorry for my bad english.
I think it could be a challenge for a wp expert… I’ve googled for days and found nothing.
I have a magazine-style wp theme. With some categories and subcategories. When in single posts, previous_post_link and next_post_link works well, but they includes the sticky post of the category (every category and subcategory has his own sticky post, wich is not intended to be properly a post, but a sort of description with links e.g. to a form). I want to exclude this sticky post from the navigation, because it ‘breaks’ the real continuity of ‘previous-next’.
An sketch of my single.php:<em>// (commented out here in WP.org) get_header, etc.</em> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php // excludes this post from 'Related posts' in the sidebar $GLOBALS['current_id'] = $post->ID; if (is_sticky()) { ?> <div id="post-<?php the_ID(); ?>" <?php post_class('sticky'); ?> <em> // (commented out here in WP.org) title, content, etc.</em> <?php } else { ?> <div class="post" id="post-<?php the_ID(); ?>"> <em>// (commented out here) title, time, entry, content, tags, etc.</em> <div class="navigation"> <div class="alignleft"><?php next_post_link('«« %link', '%title', TRUE); ></div> <div class="alignright"><?php previous_post_link('%link »»', '%title', TRUE); ?></div> </div><!--/navigation--> <div class="clear"></div> <?php comments_template(); ?> <?php } ?> <?php endwhile; else: ?> <p>some text</p> <?php endif; ?> </div><!--/content--> <?php get_sidebar(); ?> <div class="clear"></div> <?php get_footer(); ?> <?php } ?>
I’m sure it’s possible, but how? Any solution or idea? Please, without a plugin.
Thanks
- The topic ‘Exclude sticky post from navigation in single.php’ is closed to new replies.