Modify the listing list view on a custom post type

This topic contains 6 replies, has 4 voices, and was last updated by  James Gehring 5 years, 6 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #504162

    James Gehring
    Expired Member
    Post count: 34

    I am using version 2 of the plugin. I need to modify the loop on the listing list view on a custom post type.

    I only need to modify it for one custom post type.

    We made a custom review using a radio select so a person could add a review listing for a landlord. We don’t want to use the review system because these are one time reviews. In v1 I just made a template for that custom post type and added code to show stars instead of the number.

    #504182

    Kor
    Moderator
    Post count: 16516

    Hi James Gehring,

    Thanks for your post. Not really sure if I’m getting this, could you please share your Website URL here so that I could check this out? Or have you tried using custom CSS code to hide it?

    Thanks!

    #504196

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    with GDV2 you can edit the Archive and Archive item templates as WP Pages.

    Try editing the GD Archive Item template and let us know how it goes. You can find that in

    WP – Pages Search GD – Select GD Archive Item template

    https://wpgeodirectory.com/docs-v2/templates/archive-item/

    #504374

    James Gehring
    Expired Member
    Post count: 34

    Let me see if I can explain better. I have a custom field that has a radio with values 1,2,3,4,5. They select one, lets say 5. In v1 I modified the listing-listview-mycustomposttype.php file.

    I added this code to show stars instead of the number.

    if(in_array($post->geodir_landlord_rating, array(1,2,3,4,5) )){
    echo ‘<i class=”fa fa-star gd-full-star”></i>’;
    }else{
    echo ‘<i class=”fa fa-star-o gd-empty-star”></i>’;
    }

    if(in_array($post->geodir_landlord_rating, array(2,3,4,5) )){
    echo ‘<i class=”fa fa-star gd-full-star”></i>’;
    }else{
    echo ‘<i class=”fa fa-star-o gd-empty-star”></i>’;
    }

    if(in_array($post->geodir_landlord_rating, array(3,4,5) )){
    echo ‘<i class=”fa fa-star gd-full-star”></i>’;
    }else{
    echo ‘<i class=”fa fa-star-o gd-empty-star”></i>’;
    }

    if(in_array($post->geodir_landlord_rating, array(4,5) )){
    echo ‘<i class=”fa fa-star gd-full-star”></i>’;
    }else{
    echo ‘<i class=”fa fa-star-o gd-empty-star”></i>’;
    }

    if(in_array($post->geodir_landlord_rating, array(5) )){
    echo ‘<i class=”fa fa-star gd-full-star”></i>’;
    }else{
    echo ‘<i class=”fa fa-star-o gd-empty-star”></i>’;
    }

    Is there a way to accomplish this in v2?

    Page with v1 code http://crematchup.com/landlord-reviews/
    Page with v2 https://crematchuppreview.epickmarketing.com/landlord-reviews/

    #504475

    Alex Rollin
    Moderator
    Post count: 27815

    I have flagged your topic for the developers

    Thanks

    #505155

    Kiran
    Moderator
    Post count: 7069

    Hi,

    Try following PHP snippet.

    
    
    function gd_snippet_20190827_output_radio_landlord_rating( $html, $location, $cf, $p = '', $output = '' ) {
    	global $gd_post;
    
    	if ( ! empty( $gd_post ) && ! empty( $gd_post->landlord_rating ) ) {
    		$stars = '';
    
    		if ( in_array( (int) $gd_post->landlord_rating, array( 1, 2, 3, 4, 5 ) ) ) {
    			$stars .= '<i class="fa fa-star gd-full-star"></i>';
    		} else {
    			$stars .= '<i class="fa fa-star-o gd-empty-star"></i>';
    		}
    
    		if ( in_array( (int) $gd_post->landlord_rating, array( 2, 3, 4, 5 ) ) ) {
    			$stars .= '<i class="fa fa-star gd-full-star"></i>';
    		} else {
    			$stars .= '<i class="fa fa-star-o gd-empty-star"></i>';
    		}
    
    		if ( in_array( (int) $gd_post->landlord_rating, array( 3, 4, 5 ) ) ) {
    			$stars .= '<i class="fa fa-star gd-full-star"></i>';
    		} else {
    			$stars .= '<i class="fa fa-star-o gd-empty-star"></i>';
    		}
    
    		if ( in_array( (int) $gd_post->landlord_rating, array( 4, 5 ) ) ) {
    			$stars .= '<i class="fa fa-star gd-full-star"></i>';
    		} else {
    			$stars .= '<i class="fa fa-star-o gd-empty-star"></i>';
    		}
    
    		if ( (int) $gd_post->landlord_rating == 5 ) {
    			$stars .= '<i class="fa fa-star gd-full-star"></i>';
    		} else {
    			$stars .= '<i class="fa fa-star-o gd-empty-star"></i>';
    		}
    
    		$field_icon = geodir_field_icon_proccess( $cf );
    		$output = geodir_field_output_process( $output );
    		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_post_meta ' . $cf['css_class'] . ' geodir-field-' . $cf['htmlvar_name'] . '">';
    
    		if($output=='' || isset($output['icon'])) $html .= '<span class="geodir_post_meta_icon geodir-i-radio" style="' . $field_icon . '">' . $field_icon_af;
    		if($output=='' || isset($output['label']))$html .= (trim($cf['frontend_title'])) ? '<span class="geodir_post_meta_title" >'.__( $cf['frontend_title'], 'geodirectory' ) . ': '.'</span>' : '';
    		if($output=='' || isset($output['icon']))$html .= '</span>';
    		if($output=='' || isset($output['value']))$html .= $stars;
    
    		$html .= '</div>';
    	}
    
    	return $html;
    }
    add_filter( 'geodir_custom_field_output_radio_var_landlord_rating', 'gd_snippet_20190827_output_radio_landlord_rating', 11, 5 );
    

    Kiran

    #505411

    James Gehring
    Expired Member
    Post count: 34

    That worked. thanks

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

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

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount