Create a new PHP file in the root directory of the WordPress program and paste the following code
As the following code comment, modify the $CID This category ID, you can get the article under this category. This query requires a combination of three tables wp_posts, Wp_term_relationships, Wp_term_taxonomy,
According to TERM_TAXONOMY_ID get the article designator, Post_status = ' publish ' refers to the article has been published, post_type= ' post ' refers to the record type is the article, taxonomy = ' category ' refers to the type is the directory.
Then run this file and you will be able to read all the articles in this category.
<?PHPinclude("wp-config.php" ) ; require_once(Abspath. ' Wp-blog-header.php '); Global $wpdb; $CID= 1;//Category ID, only one category is supported $sql= "Select Id,post_title,post_content from Wp_posts,wp_term_relationships,wp_term_taxonomy WHERE id=object_id and Wp_ term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id and post_type= ' post ' and post_status = ' Publish ' and wp_term_relationships.term_taxonomy_id =$CIDand taxonomy = ' category ' ORDER by ID Desc '; $myrows=$wpdb->get_results ($sql); foreach($myrows as $b) { Echo $b->id. " <br/> ";//This is the article ID Echo $b->post_title. " <br/> ";//This is the article title Echo $b->post_content. " <br/> ";//This is the content of the article }?>
WordPress gets a category under all the articles by $wpdb