tags:

views:

354

answers:

1

I've tried looking at the database but I can't seem to be able to make a query to do this. How can I look up posts from only one category, or more specifically, I just need the ID of the last post from the category.

I'm trying to do this in index.php

+2  A: 

Using get_posts will do what you need, documentation here

something along the lines of the following

<?php
  $postsincat = get_posts(array("cat" => 1, "showposts" => 1));
  $idoflatestpostincategory = $postsincat[0]->ID;
?>

You could also use category_name instead of cat in the array to use a name instead of ID.

Littlejon