• I am running WP 2.3.1 with a custom home page, where I need to display a list of the four most recent posts within a certain category (“announcements”).

    Here is the code I’m using so far, but it doesn’t select for category:

    $news = $wpdb->get_results("
    	SELECT
    		ID,
    		post_title,
    		post_date,
    		post_content
    	FROM $wpdb->posts
    	WHERE
    		post_status='publish'
    	ORDER BY ID DESC LIMIT 4");
    foreach($news as $np){
    	[display results here]
    }

    How could I modify this query to display only results from a single category? My server is running MySQL 5.0, if that matters.

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Showing single category on custom home page’ is closed to new replies.