Only show custom categories marker from a specific parent
-
Hi,
I wanting to only show category markers from a specific parent. My store categories (parent and child) are as follows:
Fuel Stations
– BP
– Shell
– etc
Loyalty
– ebucks
– vitality
– etc
For example if a store has a category of Shell AND ebucks, then only get the marker from the Fuel Stations parent (ID of 12).So far I am using this but not having any succes.
function mytank_custom_store_category_image( $store_meta, $store_id ) { if ( function_exists( 'z_taxonomy_image_url' ) ) { $terms = wp_get_post_terms( $store_id, 'wpsl_store_category' ); if ( $terms ) { if ( !is_wp_error( $terms ) ) { if ( isset( $_GET['filter'] ) && $_GET['filter'] ) { $filter_ids = explode( ',', $_GET['filter'] ); foreach ( $terms as $term ) { //only return terms whose parent is Fuel Stations (ID) if ($term->parent == 12){ if ( in_array( $term->term_id, $filter_ids ) ) { $cat_marker = z_taxonomy_image_url( $term->term_id ); if ( $cat_marker ) { $store_meta['categoryMarkerUrl'] = $cat_marker; } } } } } else { $store_meta['categoryMarkerUrl'] = z_taxonomy_image_url( $terms[0]->term_id ); } } } } return $store_meta; }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Only show custom categories marker from a specific parent’ is closed to new replies.