WordPress.org

Support

Support » How-To and Troubleshooting » Calling get_categories more than once?

Calling get_categories more than once?

  • Hey!

    This is probably an incredibly easy answer and I’ve just been staring at this code for too long and can’t figure it out – but any help would be GREATLY appreciated!

    Right now what I’m trying to do is call get_categories twice to display a dropdown for all categories (excluding a few) and then one to display the children of one category.

    URL I’m using: http://metrowellness.buzzfishmarketing.com/classes-events/

    Code:

    <?php
                $categories = get_categories (
                    array(
                       'taxonomy'      => TribeEvents::TAXONOMY,
                       'selected'      => 0,
                       'exclude'      => 42,
                       'orderby'       => 'name'
                    ) );
                  ?>
                <script type="text/javascript"><!--
                function onCatChange(select) {
                    var slug = select.options[select.selectedIndex].value;
                    var link = '<?= tribe_get_events_link() ?>';
                    location.href = (slug == 'all') ? link : link + 'category/' + slug;
                }
                --></script>

    Both sets of code for the dropdowns are similar (just changes in the exclude, etc).

    [ Please do not bump, that’s not permitted here. ]

  • The topic ‘Calling get_categories more than once?’ is closed to new replies.
Skip to toolbar