How To Add Drop Down Category List To WordPress

I was working with a theme, where I wanted to give users an option to view the categories by selecting it from a drop down category list. I used the following snippet to do that job:

Which looked good, but failed! The above snippet just renders a drop down list, which doesn’t allow you to view the category archive page. So how I did that?

Only the drop down category list isn’t going to do anything, unless we have it inside a form. So, let’s just wrap our code inside a form, like this snippet:

This will do the job! We also used this function in this article.