• Ok, I’ve been looking all over the place and I can’t seem to figure out exactly how to do this.

    What I want to do is to have a home page that has some static text, and a loop (mini?) displaying the posts only from one category.

    I came up with this:
    <?php if (!in_category(7)) continue; ?>

    <div class="post" id="post-<?php the_ID(); ?>">
    <h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    <div class="storycontent">
    <?php the_content("Continue reading the " . the_title('', '', false) . " article"); ?>
    </div>
    </div>

    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>

    This, I thought, worked fine, until I started adding more content! It does the trick if, and only if, the posts in the news category (ID=7) are the very latest in date.

    So, how would I do it? Create the home page loop so it only looks up one category, and displays the posts from that category, regardless of more recent posts in other categories?

    Any ideas would be very welcome

Viewing 6 replies - 1 through 6 (of 6 total)
  • Wow that is sure a lot of code, if you just want one category to show use the front-page-filter plugin. I recently solved this problem myself.

    Hope that helps!

    Thread Starter vavroom

    (@vavroom)

    Doesn’t the front-page-plugin work on index.php, rather than home.php?

    I’m not sure but it worked for me here is the address.

    If you want to apply it to another page it might be worth altering the code in it to make it applicable to that page.

    http://smallestbusiness.com/2006/03/02/front-page-filter-plugin/

    Thread Starter vavroom

    (@vavroom)

    Thanks for that. I’ll have to look at it. I’m not much of a code jokey, so not sure about altering the code, but… One thing that I see is that the plugin doesn’t work on subdomains (well, that’s my reading of his page). Sooo, we’ll see 🙂

    Cheers

    oops

    I also have this kind of problem, but the frontpage filter page seems to be down. I have tried google and this location, but cant find it anywhere else. Is there anyone who know if i can get this plugin elsewhere?

    Thank you!

    // Jens Filipsson.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Home.php loop for only one category?’ is closed to new replies.