Give help. Get help.

  • # March 11, 2010 at 4:16 pm

    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(); ?>

    id=”post-< ?php the_ID(); ?>“>
    < ?php the_content(); ?>

    < ?php endwhile; else: ?>

    Sorry, no posts matched your criteria.

    < ?php endif; ?>

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

    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


    and header single the are:

    • < ?php previous_post_link('%link','previous') ?>
    • < ?php next_post_link('%link','Next') ?>

    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.



    # March 11, 2010 at 4:59 pm

    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 = ''); ?>
    # March 12, 2010 at 9:07 am

    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.



Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.