read out all the post title under a special category in wordpress from another system?

how to read out all the post title under a special category in wordpresss from another system?

i know how to read out all the post title. the code:

Read More
 <?php
     $dbhost = 'localhost';
     $dbuser = '..' ;
     $dbpass = '...';
    $conn = mysql_connect($dbhost, $dbuser, $dbpass);
    if(! $conn )
      {
           die('Could not connect: ' . mysql_error());
      }
      $db_selected = mysql_select_db('..');
      if (!$db_selected) {
    die ('Can't use foo : ' . mysql_error());
}
$query = "SELECT post_title,ID FROM wp_posts ORDER BY post_date DESC LIMIT 0 , 5";
$result = mysql_query($query);

how to change the query code to get five post title under a special category .thank you.

Related posts

Leave a Reply

1 comment

  1. This is a bit different than the method you are currently trying to use, but I’ve implemented this in the past simply by using the feeds provided by WordPress. This means that you don’t have to worry so much about the DB schema changing, or making DB connections from remote servers.

    All you have to do is hit the feed at:

    http://www.somewebsite.com/category/categoryname/feed

    -or-

    http://www.somewebsite.com/?cat=123&feed=rss2

    You can find more information on these feeds here: http://codex.wordpress.org/WordPress_Feeds

    Once you have the feed URL you want, you can parse it with SimplePie, DOMDocument, or SimpleXML.