How to Display Category list as select option with Link


As default WordPress  wp_dropdown_categories() function display category list as a select option but the problem is you can not get category link but it is most important that need each category link. I study by google and get solution for this Link problem here is my code

paste this code into functions.php

function get_terms_dropdown($taxonomies, $args){
    $myterms = get_terms($taxonomies, $args);
    $output ="<select class='cat_select' onChange='window.location.href=this.value'>";
    foreach($myterms as $term){
        $root_url = get_bloginfo('url');
        $term_name =$term->name;
        $link = $root_url.'/'.$term_taxonomy.'/'.$term_slug;
        $output .="<option value='".$link."'>".$term_name."</option>";
    $output .="</select>";
return $output;


Paste where you want display category list as select option with link

<?php $taxonomies = array('category');
$args = array('orderby'=>'title','hide_empty'=>true);
echo get_terms_dropdown($taxonomies, $args); ?>


$taxonomies = array('category');
$args = array('orderby'=>'count','hide_empty'=>true);
echo get_terms_dropdown($taxonomies, $args);

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!