limiting by cat in php loop
-
I know this has been addressed but I’m just not getting it. On the index php page for the site is this:
<?php
$how_many=5; //How many posts do you want to show
require_once(“blog/wp-config.php”); // Change this for your path to wp-config.php file ?><?
$news=$wpdb->get_results(“SELECTID
,post_title
FROM $wpdb->posts
WHEREpost_status
= \”publish\” ORDER BY ‘ID’ DESC LIMIT “.$how_many);
foreach($news as $np){
printf (“%s<br><br>”, $np->ID,$np->post_title);
}?>It works fine, pulling in the first 5 posts. However I need to filter out anything that is NOT in category 1.
All the info I can find shows completely different php, none of which I can get to work. Is there some way to just make what I have do what I need?
Thanks.
- The topic ‘limiting by cat in php loop’ is closed to new replies.