I have this URL:
http://example.com/?s=&cp_state=0&scat=16&sa=search&refine_search=yes
and this code on search.php
:
<?php
$searchTxt = trim( strip_tags( esc_attr( get_search_query() ) ) );
$state_append = '';
$state = $_GET['cp_state'];
if($state != '0')
$state_append = __('', APP_TD).' ' . $state;
$cat_id = $_GET['scat'];
if ( $searchTxt == __('What are you looking for? ', APP_TD) || $searchTxt == __('[All]', APP_TD) )
$searchTxt = '*';
if($searchTxt){
if($searchTxt == '*') {
if($cat = get_term_by('id', $cat_id, 'ad_cat')) {
printf( __("Ads %s %s ", APP_TD), $cat->name, $state_append, $wp_query->found_posts );
} else {
printf( __("Ads %s ", APP_TD), $state_append, $wp_query->found_posts );
}
} else {
printf( __("What are you looking for? '%s' %s ", APP_TD), $searchTxt, $state_append, $wp_query->found_posts );
}
}else{
$searchTxt = trim( strip_tags( esc_attr( get_search_query() ) ) );
printf( __("What are you looking for? '%s' %s ", APP_TD), $searchTxt, $state_append, $wp_query->found_posts );
}
echo $cat_id;
?>
I would like to get the category name of the URL.
I try to use echo $cat_id
, but it gives me the number and not the name of the category.
How can I "echo" the name of category instead the number?