Asked 30+ days ago
27 Jun 2017
Views 106
Cimb

Cimb posted

How to get posts by category id or category name in wordpress ?


 
global $wpdb, $post;
 
$str    = "SELECT $wpdb->posts.* FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'";
$result = $wpdb->get_results( $str );



where can i put category name or category id to get posts for particular category ?
Post Answer