WordPress.org

Support

Support » How-To and Troubleshooting » Mini-Loop grabbing ONLY a specific category

Mini-Loop grabbing ONLY a specific category

  • 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:

    http://codex.wordpress.org/Creating_a_Static_Front_Page

    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 (”

  • %s
  • “, $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?

  • The topic ‘Mini-Loop grabbing ONLY a specific category’ is closed to new replies.
Skip to toolbar