WordPress.org

Ready to get started?Download WordPress

Forums

Single Post template shows other posts from same category (3 posts)

  1. retardedjimmy
    Member
    Posted 8 years ago #

    There are a few questions floating around about this, but none of them seem to have any definitive answers, so I'll try one more time.

    I'm trying to put other posts from the same category below the post on my single post page (you can see a good example at defamer.com). Here's the code I've got so far (directly after and outside of the loop):


    <?php $cat = get_the_category(); ?>
    <?php $cat = trim($cat[0]->cat_name); ?>

    <?php query_posts('category_name="$cat"&showposts=15'); ?>
    <?php while (have_posts()) : the_post(); ?>
    blah blah blah
    <?php endwhile; ?>

    Not only does this not work (no output at all), but I'm worried that even if I do get it to work, it will query even the post that I already have showing at the top of the page, to make sure that wp doesn't also show it down below. Any ideas on this?

  2. moshu
    Member
    Posted 8 years ago #

    First of all, I am not sure that site is a WP powered blog: in the credit section there is an empty space about the software.
    Next, what you percieve as "single page with many posts" (which is an oxymoron, BTW) are category archives. Just watch the URL! The only thing is the post titles don't link to the post permalink, but to the category page.

  3. retardedjimmy
    Member
    Posted 8 years ago #

    Thanks for the answer. I'm pretty sure Defamer is not a WP blog, I just think they have a nice style, and I'm trying to emulate it.

    However, I do notice that you're right. It's only their front page that links to the category pages, and that way the latest post will be on top no matter what. Any permalinked post off the front page seems to just be a normal single post page. Their URL query is strange, but I guess that's what they're doing.

    What I could do, then, is just make sure that any links off the home page (is_home()) go to category archives instead of single post archives. This seems unwieldy, as I'd have to make clear that links on the home page aren't actually permalinks, they're category links. Would give visitors more to read on single pages, but wouldn't let them link offsite as easily...

Topic Closed

This topic has been closed to new replies.

About this Topic