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-
AuthorPosts
-
August 21, 2019 at 2:03 pm #504162
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.
August 21, 2019 at 3:41 pm #504182Hi 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!
August 21, 2019 at 5:10 pm #504196Hello,
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
August 22, 2019 at 2:09 pm #504374Let 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/August 22, 2019 at 10:45 pm #504475I have flagged your topic for the developers
Thanks
August 27, 2019 at 2:13 pm #505155Hi,
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
August 28, 2019 at 8:27 pm #505411That worked. thanks
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket