WordPress order categories by ID

Question

I am new to get terms and wanted to know if someone can help me.

How can I get this to show my categories in order or id that I want?

I want to show a number of categories in a specific order from a drop down.

Thanks!

<div class="event_filter_item">
        <?php
            $categories = get_terms( 'event-category' );

            $dropdown_options = array(
                "theme" => "dropdown_base",
                "label" => "Events by Category",
                'orderby' => 'ID',
'include' => '155',
                "links" => true
            );
        ?>
        <label class="event_filter_label" for="event_filter_category">Events by Category</label>
        <select class="js-dropdown event_filter_select event_filter_category" id="event_filter_category" name="event_filter_category" data-dropdown-options="<?php my_json_attribute( $dropdown_options ); ?>">
            <option value="<?php my_page_link( 'calendar' ); ?>">All Categories</option>
            <?php
                foreach ( $categories as $category ) :
                    $link = get_term_link( $category->term_id );
                    $attr = ( strpos( $my_page_url, $link ) > -1 ) ? 'selected="selected"' : '';
            ?>
            <option value="<?php echo $link; ?>" <?php echo $attr; ?>><?php echo $category->name; ?></option>
            <?php
                endforeach;
            ?>
        </select>
    </div>
0
Jimmy Lopez 4 years 2017-08-02T11:09:21-05:00 0 Answers 80 views 0

Leave an answer

Browse
Browse