Get WP Posts in Category

August 24, 2020

List the  WP posts when category is given

If you need to run custom query you can use the WP_Query()

In the following example you can get the all posts in the category where the ID is equal to 10



$category_query_args = array(
   'cat' => 10
);

$category_query = new WP_Query($category_query_args);


if ($category_query->have_posts()) {
    while ($category_query->have_posts()){
         $category_query->the_post();
       //  echo  get_the_ID();
	//  ech0  get_the_permalink()

    }
}