WordPress.org

Support

Support » Themes and Templates » Sampression Lite » [Resolved] Specify which categories appear in filter navigation

[Resolved] Specify which categories appear in filter navigation

  • hi,

    I have about 20 categories but only want my users to be able to filter by 5 of those 20 categories. Can i somehow limit which categories appear in the filter menu?

    I’ve been looking at this code in the head.php

    <?php if(is_page()): ?>
    <nav id="primary-nav">
      <div class="container">
      <a href="#">show/hide</a>
      <div class="columns sixteen">
        <div class="nav-label"><?php _e('Filter By:','sampression'); ?></div>
    
        <ul class="nav-listing clearfix">
    
    <li><a href="#"><span></span><?php _e('Show All','sampression'); ?></a></li>
            <?php
            $categories = get_categories();
            foreach($categories as $category):
            ?>
    
    <li><a href="void(0);">slug; ?>" id="<?php echo $category->slug; ?>" class="filter-data"><span></span><?php echo $category->name; ?></a></li>
            <?php
            endforeach;
            ?>

    I suspect it has something to do with <?php echo $category->name; ?>

Viewing 1 replies (of 1 total)
  • I figured this out, in the header.php added and include for the category IDs, so this code with nothing in the () shows all cats.

    $categories = get_categories();

    this code shoes only cats with the IDs of 202, 14, and 82

    $categories = get_categories('include=202,14,82');

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Specify which categories appear in filter navigation’ is closed to new replies.
Skip to toolbar