Support » Fixing WordPress » Custom database query selecting posts of one category

Viewing 6 replies - 1 through 6 (of 6 total)
  • Aren’t you overcomplicating it?
    Why not just edit out/delete the_content tga from a category template and you are done.

    Yeah, that’s way overkill. Never do custom SQL when the code can do it for you.

    <?php
    query_posts('cat=6&showposts=5');
    if (have_posts()) {
    echo '<ul class="list-cat">';
    while (have_posts()) { the_post();
    ?><li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php
    } // end while loop
    echo '</ul>';
    } // end if
    wp_reset_query();
    ?>

    Unless I’m misunderstanding the category template, I think I need something more. I’m trying to populate a list with recent posts of a certain category on the main page of a blog. This seemed like the simplest solution to me, but I’m not extremely familiar with WordPress.

    The site is http://f-investors.com/, and the area I am trying to create a list in is below the “What’s New” header at the bottom left of the page.

    Excellent Otto, that did the trick. I can never figure out the best way to implement something. Thanks!

    I’m looking to do something similar here. Is it possible in v2.5?
    Thx

    Hi

    I am trying to do something similar. I actually have a suckerfish menu that I am trying to list the last 10 posts from a certain category. Here is the code:

    <li><a href="http://www.uniquecards.org/category/print-training-and-tips/">Print Training and Tips</a>
    <ul>
    <?php
    query_posts('cat=3&showposts=5');
    if (have_posts()) {
    while (have_posts()) { the_post();
    ?><li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php
    } // end while loop
    } // end if
    wp_reset_query();
    ?>
    </ul>
    </li>

    And a link to the page:
    The Page

    As you can see no drop down is created. Any ideas why please?

    Thanks

    Rich

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Custom database query selecting posts of one category’ is closed to new replies.