Mini-Loop grabbing ONLY a specific category (1 post)

  1. aluminumcans
    Posted 10 years ago #

    I'm new to both PHP and WordPress templates (coming from ASP.net + MsSQL).

    I've managed to create a static home page and would like to use a couple of mini-loops on the home page in different areas each grabbing a specific category.

    This is the sample:


    And the specific bit of code:

    $news=$wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts
    WHERE post_status= \"publish\" ORDER BY 'ID' DESC LIMIT ".$how_many);
    foreach($news as $np){
    printf ("

  2. %s
  3. ", $np->ID,$np->post_title);

    Now, maybe this is just a simple matter of me figuring out the DB fields and learning the JOIN syntax for mySQL. However, when googling for answers, I get all sorts of mentions of setting various variables or using plugins to acomplish category-specific filtering. Is changing the raw query NOT the suggested method?

Topic Closed

This topic has been closed to new replies.

About this Topic