Remove comma from category list
This topic contains 10 replies, has 3 voices, and was last updated by Andrea Piaggesi 7 years, 9 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
July 18, 2017 at 11:25 am #387501
Hi,
is there a way to remove commas and the last “and” from the category list?Thanks!
AndreaJuly 18, 2017 at 5:36 pm #387574Hi,
I asked to the developers to check if there is a hook and to let us know,
Thanks
July 18, 2017 at 5:55 pm #387582function geodir_cf_taxonomy_modified($html,$location,$cf,$p=''){ // check we have the post value if(is_int($p)){$post = geodir_get_post_info($p);} else{ global $post;} if(!is_array($cf) && $cf!=''){ $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type); if(!$cf){return NULL;} } $html_var = $cf['htmlvar_name']; // Check if there is a location specific filter. if(has_filter("geodir_custom_field_output_taxonomy_loc_{$location}")){ /** * Filter the taxonomy html by location. * * @param string $html The html to filter. * @param array $cf The custom field array. * @since 1.6.6 */ $html = apply_filters("geodir_custom_field_output_taxonomy_loc_{$location}",$html,$cf); } // Check if there is a custom field specific filter. if(has_filter("geodir_custom_field_output_taxonomy_var_{$html_var}")){ /** * Filter the taxonomy html by individual custom field. * * @param string $html The html to filter. * @param string $location The location to output the html. * @param array $cf The custom field array. * @since 1.6.6 */ $html = apply_filters("geodir_custom_field_output_taxonomy_var_{$html_var}",$html,$location,$cf); } // Check if there is a custom field key specific filter. if(has_filter("geodir_custom_field_output_taxonomy_key_{$cf['field_type_key']}")){ /** * Filter the taxonomy html by field type key. * * @param string $html The html to filter. * @param string $location The location to output the html. * @param array $cf The custom field array. * @since 1.6.6 */ $html = apply_filters("geodir_custom_field_output_taxonomy_key_{$cf['field_type_key']}",$html,$location,$cf); } // If not html then we run the standard output. if(empty($html)){ if ($html_var == $post->post_type . 'category' && !empty($post->{$html_var})) { $post_taxonomy = $post->post_type . 'category'; $field_value = $post->{$html_var}; $links = array(); $terms = array(); $termsOrdered = array(); if (!is_array($field_value)) { $field_value = explode(",", trim($field_value, ",")); } $field_value = array_unique($field_value); if (!empty($field_value)) { foreach ($field_value as $term) { $term = trim($term); if ($term != '') { $term = get_term_by('id', $term, $html_var); if (is_object($term)) { $links[] = "<a href='" . esc_attr(get_term_link($term, $post_taxonomy)) . "'>" . $term->name . "</a>"; $terms[] = $term; } } } if (!empty($links)) { // order alphabetically asort($links); foreach (array_keys($links) as $key) { $termsOrdered[$key] = $terms[$key]; } $terms = $termsOrdered; } } $html_value = !empty($links) && !empty($terms) ? $links : ''; if (is_array($html_value)) { $html_value = implode(' ', $html_value); } if ($html_value != '') { $field_icon = geodir_field_icon_proccess($cf); if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } else if ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $html_var . '" style="clear:both;"><span class="geodir-i-taxonomy geodir-i-category" style="' . $field_icon . '">' . $field_icon_af; $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span> ' . $html_value . '</div>'; } } } return $html; } remove_filter('geodir_custom_field_output_taxonomy','geodir_cf_taxonomy',10); add_filter('geodir_custom_field_output_taxonomy','geodir_cf_taxonomy_modified',10,3);
July 18, 2017 at 8:02 pm #387604Hi,
sorry but I’ve just added the code to my functions.php and the commas are still there.Thanks!
AndreaJuly 18, 2017 at 8:05 pm #387605hi,
please provide a link and admin credentials and we will have a look.
Thanks
July 18, 2017 at 8:09 pm #387606This reply has been marked as private.July 18, 2017 at 8:15 pm #387607Hi,
I alerted Giri, he’ll let you know asap.
Thanks for your patience,
July 19, 2017 at 11:39 am #387671Hi there,
The code I given earlier is for the categories you see in sidebar. For the top part use this code.
add_filter('geodir_details_taxonomies_output', 'geodir_details_taxonomies_output_commaless', 10, 4); function geodir_details_taxonomies_output_commaless($taxonomies, $post_type,$listing_label, $listing_label_uc) { if (!geodir_is_page('detail')) { return $taxonomies; } $post_taxonomy = $post_type . 'category'; if (isset($taxonomies[$post_taxonomy])) { $taxonomies[$post_taxonomy] = str_replace("</a> and <a", "</a><a", $taxonomies[$post_taxonomy]); $taxonomies[$post_taxonomy] = str_replace("</a>, and <a", "</a><a", $taxonomies[$post_taxonomy]); $taxonomies[$post_taxonomy] = str_replace("</a>, <a", "</a><a", $taxonomies[$post_taxonomy]); } return $taxonomies; }
July 19, 2017 at 10:22 pm #387766Thank you very much, that worked!
Please can you point me to the correct hooks for editing the Grid View Listings content.
I would like to add some informations to each listing of the Grid View, for example some xprofile informations of the BuddyPress author profile.Thank you very much.
AndreaJuly 19, 2017 at 10:29 pm #387768Hi,
To add anything to listings in widget and listings pages you have the action:
do_action('geodir_after_listing_post_excerpt', $post);
Please open new topics for any new question, this is resolved and we’re going off topic now.
Thanks
July 20, 2017 at 2:14 pm #387848Okkk thank you very much for the help.
Andrea -
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket