Answers for "wp query by category slug wordpress"

PHP
3

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
0

wordpress get current category slug

$category = get_category(get_query_var('cat'));
echo $category->slug; 
// Echo the category slug of default taxonomy (Category)
Posted by: Guest on March-13-2022

Browse Popular Code Answers by Language