Display Categories Normally or in Drop-Down Box


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <h2>Categories</h2>
  2. <ul>
  3. <?php wp_list_cats('sort_column=name'); ?>
  4. </ul>
  5.  
  6.  
  7.  
  8. <form action="<?php bloginfo('url'); ?>/" method="get">
  9. <?php
  10. $select = wp_dropdown_categories('show_option_none=Select category&show_count=1&orderby=name&echo=0');
  11. $select = preg_replace("#<select([^>]*)>#”, “<select$1 onchange=’return this.form.submit()’>”, $select); echo $select; ?>
  12. <noscript><input type=”submit” value=”View” /></noscript>
  13. </form>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.