<select name="g-cats" id="g-cats" onchange="location = this.value;">
<option value="">Filter by Category</option>
<option value=".">ALL</option>
<option value="?gm14[category__in]=4">MEN</option>
<option value="?gm14[category__in]=5">WOMEN</option>
</select>
I’m doing something like this now, wondering if I can get all the existing categories in the theme file.
thank you.
Plugin Author
Rattus
(@pasyuk)
<select name="g-cats" id="g-cats" onchange="location = this.value;">
<option value="">Filter by Category</option>
<option value=".">ALL</option>
<?php
global $gmDB;
$gmedia_categories = $gmDB->get_terms( 'gmedia_category', [ 'fields' => 'id=>names', 'orderby' => 'name', 'order' => 'ASC' ] );
foreach ( $gmedia_categories as $cat_id => $gm_cat ) {
echo '<option value="?gm14[category__in]=' . (int) $cat_id . '">' . esc_html( $gm_cat ) . '</option>';
}
?>
</select>
one more thing, this above code will refresh the page upon selection right?
is it possible to filter categories without refreshing the page, ajax like?
thank you.
Plugin Author
Rattus
(@pasyuk)
There are gallery modules where you can display categories as albums (actually all that modules has ‘album’ word in the module’s name) and load them via ajax. Just select [NOT IN] Categories = “Uncategorized” in a “Build Query” popup. There is no other way to load categories via ajax.