Answers for "wp_query get category list"

PHP
2

category name wp query

$query = new WP_Query( array( 'category_name' => 'staff' ) );

cat (int) – use category id.
category_name (string) – use category slug.
category__and (array) – use category id.
category__in (array) – use category id.
category__not_in (array) – use category id.
Posted by: Guest on November-08-2020
1

get the category wp

//get category name foolproof 
echo (!empty(get_the_category($post)) ? get_the_category($post)[0]->name : '');
Posted by: Guest on September-09-2021

Browse Popular Code Answers by Language