Skip to content



Theme Tweaks: Add Dropdown Category

Ready to get a little geeky? Okay, maybe a lot geeky?

I am often asked about little tweaks to the average WordPress theme, so I thought I would run through some of the most popular tweaks over the next few posts.

Display Category Dropdown Outside Of Sidebar

Most blog themes will allow you to display your categories in the sidebar. The category widget also has a couple of options like *display as dropdown* or *show hierarchical view*. But how to do you include a category dropdown outside of the sidebar?

Goal

Create a dropdown category list (in hierarchical view) and allow the visitors to click a GO button to see only posts in that category. Place it in the header area of the blog rather than the sidebar.

Code

A couple of notes: I created a style rule for the id “all-categories” so I could apply formatting specific to ONLY this section of the header. This allowed me to float it to the right, set the font size and padding.

Explanation of each element

  • <?php bloginfo(“url”); ?>: This instructs WordPress to go get the URL for the current blog page.
  • wp_dropdown_categories() is a built in function to allow you to display a drop down list. It takes a single parameter, broken into pieces (shown below):
    • orderby=name : The most standard of the order by clauses, this says put it in name order. Additional choices are author, date, title, modified, menu_order, parent, ID, rand, and none.
    • order=ASC : Using the orderby clause, which direction should it sort? Ascending and descending are your two choices.
    • show_count=1 : Do you want to include a number of posts count at the end? 0 = False, and 1 = True
    • hierarchical=1 : Do you want to show the list in hierarchical view? (With sub-categories indented under categories). 0 = False and 1 = True
    • show_option_all=Category Archives : Text to display for showing an all categories option. Default will not show an option to select all.
    • Not shown, but an option: exclude=123,345 : Include this using the ID’s of the categories you don’t want to include and they will not be shown in the dropdown list
    • Other options can be found here; http://codex.wordpress.org/Function_Reference/wp_dropdown_categories

Got something you want to see explored or explained? Drop me a comment and I will include it!

About The Author

Cenay Nailor is an Internet, Affiliate and Networking Marketing success coach with mad technical skills she loves sharing. Visit her blog and sign up for a weekly injection of Tech-Based Marketing help, sent right to your inbox. http://www.CenayNailor.com


About The Author

Dali Burgado, also known as "The Dali Blogger" teaches creative entrepreneurs how to carve a web presence that connects with their Inner Guru and their target audience. Her first online marketing love is SEO. She's an avid connector on Facebook, Twitter, and Google+. When she's not coaching or teaching, she's tweaking sites for Search Engine Visibility, working on her PHP and Javascript coding skills, Singing Opera, or learning about gardening. Circle Dali on Google+

If you enjoyed this post, make sure you subscribe to my RSS feed!

Recommended Tools for Web Success

Below are two of my highly recommended tools for building an effective online presence.

  1. Market Samurai: Comprehensive Keyword Research Tool
  2. Elegant Themes: Premium WordPress Themes
Try Market Samurai now for free!


Posted in Blog Tweaks and Tips. Tagged with , , , , , , , , , , , .

2 Tweets

9 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Man Paul, you must’ve been waiting for the next post, you Tweet’d it moments after I posted it!

    Thanks!

  2. Gorilla marketing in today’s economy is everything, marketing to get through the recession!
    If your interested in web optimization for your site, there is a free site for uploading video ads for your business, they also have image uploads if you are not yet up to videos. The more sites you can link to the greater your market will be. They have a free link exchange as well.

     http://adwido.com

  3. Hi everyone, if your starting, or have a small business, and want more customers check out http://adwido.com a free site for uploading video ads for your business,they also have image uploads if you are not yet up to videos. The more sites you can link to the greater your market will be. They have a free link exchange as well.

  4. Aiba said

    Hi Cenay, I had a problem.

    <form action="” method=”get”>

    This is a code, but it only work with last drop-down, the first 2 are not included when submit, can ypu halp me?

  5. @Aiba, I have seen this problem before when there is more than one form on a page (something you should avoid if possible).

    The form action should be the URL where the form is located. Also, each input must be within the form tags. In other words,

    <form> ...allthe inputs here</form>

    Please note, I added a space so I could display it here, please remove both spaces in both tags.

    I hope this helps.

Continuing the Discussion

  1. Theme Tweaks Add Dropdown Category Small Business Internet | internet marketing tools linked to this post on June 19, 2009

    [...] Theme Tweaks Add Dropdown Category Small Business Internet Posted by root 3 days ago (http://secretstowebsuccess.com) Cenay nailor is an internet affiliate and networking marketing success coach with mad technical skills she loves sharing this comment was originally posted on twitter reply quote proudly powered by wordpress and carrington Discuss  |  Bury |  News | Theme Tweaks Add Dropdown Category Small Business Internet [...]

  2. Customize Tag Cloud Appearance To Help Visitors Find Your Content : Blogging Your Brand with Wordpress | Cenay Nailor linked to this post on November 4, 2011

    [...] Theme Tweaks: Add Dropdown Category (secretstowebsuccess.com) [...]

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.

CommentLuv badge

Additional comments powered by BackType