How to Limit WordPress Menu Categories?

Discussion in 'WordPress' started by Jalpari, Mar 11, 2009.

  1. #1
    If i want to show only 6 categories or limit them, in header menu bar (header cat) how i can do?

    My blog is listed under my recent blog, see in sky blue bar. ;)
     
    Jalpari, Mar 11, 2009 IP
  2. craiger22

    craiger22 Well-Known Member

    Messages:
    1,472
    Likes Received:
    99
    Best Answers:
    0
    Trophy Points:
    170
    #2
    You could do it a few ways.

    You could do it by including categories, suppose you only want to show category numbers 1,3,5

    <?php wp_list_categories('orderby=name&include=1,3,5'); ?>
    Code (markup):
    Suppose you want to define categories you DONT want shown, category id 2,4,6 for example:

    <?php wp_list_categories('orderby=name&exclude=2,4,6'); ?>
    Code (markup):
    Or if you just want to show the first 6 categories:

    <?php wp_list_categories('orderby=name&number=6'); ?>
    Code (markup):
    I hope this helps
     
    craiger22, Mar 11, 2009 IP
  3. Jalpari

    Jalpari Notable Member

    Messages:
    5,640
    Likes Received:
    137
    Best Answers:
    0
    Trophy Points:
    260
    #3
    I change this line in menu widgets but not work. my menu widgets file code is

     
    <div id="menu">
     <ul>
     <li<?php if(!is_category() && !is_page()) { ?> class="current-cat"<?php } ?>><a href="<?php bloginfo('home'); ?>/" title="Home">Home</a></li>
     <?php wp_list_categories('orderby=ID&order=ASC&depth=2&hide_empty=0&title_li='); ?>
     </ul>
     
     <form class="searchform" method="get" action="<?php bloginfo('url'); ?>/">
      <fieldset>
       <input type="text" value="<?php the_search_query(); ?>" name="s" class="searchfield" />
       <input type="submit" value="" class="searchbutton" />
      </fieldset>
     </form>
    </div>
    
    PHP:
     
    Jalpari, Mar 12, 2009 IP
  4. craiger22

    craiger22 Well-Known Member

    Messages:
    1,472
    Likes Received:
    99
    Best Answers:
    0
    Trophy Points:
    170
    #4
    Just add it like this and it should work.

    <div id="menu">
     <ul>
     <li<?php if(!is_category() && !is_page()) { ?> class="current-cat"<?php } ?>><a href="<?php bloginfo('home'); ?>/" title="Home">Home</a></li>
     <?php wp_list_categories('orderby=ID&order=ASC&depth=2&hide_empty=0&title_li=&number=6'); ?>
     </ul>
     
     <form class="searchform" method="get" action="<?php bloginfo('url'); ?>/">
      <fieldset>
       <input type="text" value="<?php the_search_query(); ?>" name="s" class="searchfield" />
       <input type="submit" value="" class="searchbutton" />
      </fieldset>
     </form>
    </div>
    PHP:
     
    craiger22, Mar 13, 2009 IP
    Jalpari and Tom Thumb like this.
  5. netaddict41

    netaddict41 Well-Known Member

    Messages:
    416
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    155
    Digital Goods:
    1
    #5
    wow I wanted to know that too. Thanks Craiger
     
    netaddict41, Mar 13, 2009 IP
  6. Jalpari

    Jalpari Notable Member

    Messages:
    5,640
    Likes Received:
    137
    Best Answers:
    0
    Trophy Points:
    260
    #6
    It works but problem was lying under theme file.
     
    Jalpari, Mar 13, 2009 IP