0

I am trying to show only selected categories (or taxomony) from the dropdown, right now my code jumps off to another page of the selected category. How Can i do that?

$option ;
$categories = get_categories(); 
foreach ($categories as $category) {
    $option .= '<option value="'.get_option('home').'/category/'.$category->slug.'">';
    $option .= $category->cat_name;
    //$option .= ' ('.$category->category_count.')';
    $option .= '</option>';
}
echo $option;

1 Answer 1

0

You should be using get_term_link( $category->slug,'category' ) to get the category url refer link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.