• Resolved esmaeili

    (@esmaeili)


    Thank you for the awesome plugin.

    is there an API to get all the categories and show them in frontend so the user can filter the images?
    or should we do it hard-coded with links one by one?

    PS: I’m using shortcode on a custom page.

    Your help is highly appreciated.

    • This topic was modified 3 years, 7 months ago by esmaeili.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter esmaeili

    (@esmaeili)

    <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>
    Thread Starter esmaeili

    (@esmaeili)

    perfect thank you

    Thread Starter esmaeili

    (@esmaeili)

    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Filter by Category in front end’ is closed to new replies.