Hide the word and in taxonomy and category list

This topic contains 5 replies, has 4 voices, and was last updated by  Bernward Maspohl 4 years, 2 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #529273

    Bernward Maspohl
    Full Member
    Post count: 65

    Hi there,

    In the lists of tags and categories (Listings and Sidebar) there is always an ‘and’ at the end. How or where can I remove it? I only need the comma.

    Thanks!
    Bernward

    #529313

    Alex Rollin
    Moderator
    Post count: 27815

    It may be possible to hide with Custom CSS. Can you share a link to the page?

    #529316

    Bernward Maspohl
    Full Member
    Post count: 65
    This reply has been marked as private.
    #529438

    Kor
    Moderator
    Post count: 16516
    This reply has been marked as private.
    #529606

    Kiran
    Moderator
    Post count: 7069

    Hi Bernward,

    Category & tags values are displayed via PHP format “%l”. You can use following PHP snippet to replace “and” to “,”.

    
    
    /**
     * Replace ", and", " and " in listing category/tags value.
     */
    function gd_snippet_200210_taxonomy_replace_and( $html, $location, $cf, $p = '', $output = '' ) {
    	if ( ! empty( $html ) && (  empty( $p->options['base_id'] ) || ( ! empty( $p->options['base_id'] ) && $p->options['base_id'] == 'gd_single_taxonomies' ) ) ) {
    		$replace = ', '; // Replace string.
    
    		$html = str_replace( array( '</a>' . sprintf( __( '%1$s, and %2$s' ), '', '' ) . '<a', sprintf( '</a>' . __( '%1$s and %2$s' ) . '<a', '', '' ) ), array( '</a>' . $replace . '<a', '</a>' . $replace . '<a' ), $html );
    	}
    
    	return $html;
    }
    // Listing pages
    add_filter( 'geodir_custom_field_output_tags', 'gd_snippet_200210_taxonomy_replace_and', 20, 5 );
    add_filter( 'geodir_custom_field_output_categories', 'gd_snippet_200210_taxonomy_replace_and', 20, 5 );
    add_filter( 'geodir_custom_field_output_taxonomy', 'gd_snippet_200210_taxonomy_replace_and', 20, 5 );
    
    // Detail page gd_single_taxonomies
    add_filter( 'wp_super_duper_widget_output', 'gd_snippet_200210_taxonomy_replace_and', 20, 4 );

    Regards,
    Kiran

    #529618

    Bernward Maspohl
    Full Member
    Post count: 65

    Hi Kiran,

    Thank you very much for this solution. It works wonderfully.

    Regards,
    Bernward

Viewing 6 posts - 1 through 6 (of 6 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket