jeudi 20 février 2020

only display items in category bar when there are multiple different items

so I have this small piece of code that displays the categories in some sort of navbar. clicking one of the categories like u would expect displays all items in that category.

on default when none of the categories are pressed it displays all items from all categories.

what it used to be like

    <div class="highlighted_vacancies__choices">
        <p value="all" class="selected">Alles</p>
        <?php foreach ($filters as $filter): ?>
            <p value="<?php echo $filter; ?>"><?php echo get_field('name', $filter); ?></p>
        <?php endforeach; ?>
    </div>

what i've tried to get it like how I want it to be

<div class="highlighted_vacancies__choices">
    <p value="all" class="selected">Alles</p>
    <?php foreach ($filters as $filter): ?>
        <?php
        if ($filter > 1): ?>
            <p value="<?php echo $filter; ?>"><?php echo get_field('name', $filter); ?></p>
        <?php endif; ?>
    <?php endforeach; ?>
</div>

what i've tried is probably horrible wrong. I normally don't really use PHP that much :D

any help / suggestions are welcome

Aucun commentaire:

Enregistrer un commentaire