Show checkbox results without "yes"

This topic contains 4 replies, has 3 voices, and was last updated by  Emily Tarrant 6 years ago.

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

Open Support Ticket
  • Author
    Posts
  • #426897

    Emily Tarrant
    Expired Member
    Post count: 15

    Hi folks

    I’ve got a series of checkboxes set to demonstrate facilities. They are currently displaying with the checkbox name followed by “: Yes”, for example:

    Credit Cards: Yes
    Internet Access: Yes
    No Smoking: Yes

    Is it possible to set this so the it shows the name without the yes?

    Credit Cards
    Internet Access
    No Smoking

    I’m sure I’m missing something obvious! I’d be grateful if you could point me in the right direction.

    Cheers, Emily

    #426929

    Alex Rollin
    Moderator
    Post count: 27815

    Hello Emily,

    It might be possible to hide the Yes with CSS.

    Please send over an example URL and point out where we should be looking and we will see if we can help.

    You can use a private reply, here, and share WP Admin in case we need it for settings.

    #426962

    Emily Tarrant
    Expired Member
    Post count: 15
    This reply has been marked as private.
    #427067

    Kiran
    Moderator
    Post count: 7069

    Hi Emily,

    Add following code snippet in your theme functions.php file or add via any snippet plugin.
    Following code will remove “Yes” text for checkbox fields.

    
    
    function _gd_custom_hide_checkbox_yes( $html, $location, $cf ) {
        global $post;
    
        if ( ! is_array( $cf ) && $cf != '' ) {
            $cf = geodir_get_field_infoby( 'htmlvar_name', $cf, $post->post_type );
        }
    	if ( empty( $cf ) ) {
    		return NULL;
    	}
    
    	$html_var = $cf['htmlvar_name'];
    	if ( ! empty( $post ) && (int) $post->{$html_var} == 1 ) {
    		$field_icon = geodir_field_icon_proccess( $cf );
    		if ( strpos( $field_icon, 'http' ) !== false ) {
    			$field_icon_af = '';
    		} elseif ( $field_icon == '' ) {
    			$field_icon_af = '';
    		} else {
    			$field_icon_af = $field_icon;
    			$field_icon = '';
    		}
    
    		$html = '<div class="geodir_more_info  ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-checkbox" style="' . $field_icon . '">' . $field_icon_af;
    		$html .= ( trim( $cf['site_title'] ) ) ? __( $cf['site_title'], 'geodirectory' ) : '';
    		$html .= '</span></div>';
    	}
    
        return $html;
    }
    add_filter( 'geodir_custom_field_output_checkbox_key_checkbox', '_gd_custom_hide_checkbox_yes', 10, 3 );

    Thanks,
    Kiran

    #427252

    Emily Tarrant
    Expired Member
    Post count: 15

    Perfect! Thanks Kiran

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

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

Open Support Ticket