WordPress.org

Ready to get started?Download WordPress

Forums

Sampression Lite
[resolved] Specify which categories appear in filter navigation (2 posts)

  1. ceh
    Member
    Posted 1 year ago #

    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; ?>

  2. ceh
    Member
    Posted 1 year ago #

    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');

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags

No tags yet.