treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] tumblelog/wordpress question

  • hello all!

    i'm working on a blog that shows one post per page - using this code on my index page

    	<?php query_posts('posts_per_page=1'); ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <div <?php post_class() ?> id=\"post-<?php the_ID(); ?>\">
    <?php the_content(); ?>
    </div>
    <?php endwhile; else: ?>
    <p>Sorry, no posts matched your criteria.</p>
    <?php endif; ?>


    what i'm trying to to is implement something like this:

    http://perishablepress.com/press/2006/11/22/perishable-press-triple-loop-for-wordpress/

    so i can show tumblelog style posts in my footer.

    i have the code working just fine. it shows the tumblelog style posts in the footer, but what i'm trying to do is keep my main posts separate from my tumblelog style posts. as it stands, when i hit previous - and go to my single.php, it takes me to whatever the previous post is - whether or not it's a tumblelog or main post catagory.

    my next previous links on my main header are
    	<ul id=\"right-nav\" >
    <?php query_posts('posts_per_page=1&offset=1'); the_post(); ?>
    <li><a href=\"<?php the_permalink() ?>\" rel=\"prev\">previous</a></li>
    <?php wp_reset_query(); ?>
    </ul><!-- end ul#right-nav -->


    and header single the are:
    	<ul id=\"right-nav\" class>
    <li><?php previous_post_link('%link','previous') ?></li>
    <li><?php next_post_link('%link','Next') ?></li>
    </ul><!-- end ul#right-nav -->


    what i mean is, i only want the main posts to show up on single php and i want my tumblelog style posts to remain in the footer.

    does that make sense? i really appreciate any help that can be provided.

    cheers,

    DSD.
  • You can use the $in_same_cat parameter to restrict navigation to the category of the current post. Alternatively you can set $excluded_categories to the categories you want to exclude. (It's a bit of a strange syntax, you use $excluded_categories = "1 and 7 and 8 and 31" ).
    <?php previous_post_link($format, $link, $in_same_cat = false, $excluded_categories = ''); ?>
  • I guess I should have done a little searching on the topic as this info is readily available right there in the codex. I've implemented your code and it's working perfectly. Thank you for your quick reply. It was a big help.

    Cheers,

    D