no review php
This topic contains 7 replies, has 4 voices, and was last updated by Mitch Canton 5 years, 8 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: post_class, snippet
-
AuthorPosts
-
April 5, 2019 at 2:56 am #478429
In v1 I had used some code (in conjunction with a line of CSS):
function _gd_custom_hide_no_review_text( $class ) { global $post; if ( empty( $post->rating_count ) ) { $class .= 'gd-custom-no-review'; } return $class; } add_filter( 'geodir_post_view_article_extra_class', '_gd_custom_hide_no_review_text', 10, 1 );
.gd-custom-no-review .geodir-entry-meta a.geodir-pcomments {display: none !important;}
This code/css combo doesn’t seem to work in v2. Could you please let me know what I need to do to make this work in v2?
Thanks.
April 5, 2019 at 5:50 am #478454Hi Mitch Canton,
Thanks for your post. Will forward this to a developer for further assistance.
April 5, 2019 at 10:27 am #478525Hello Mitch,
For GeoDirectory v2 use following snippet.
/** * Add CSS class to listing layout for empty rating. */ function gd_snippet_hide_no_review_text( $classes, $class, $post_ID ) { global $gd_post; if ( ! empty( $post_ID ) && ! empty( $gd_post ) && ! empty( $gd_post->ID ) && $gd_post->ID == $post_ID && empty( $gd_post->rating_count ) ) { $classes[] = 'gd-custom-no-review'; // CSS class } return $classes; } add_filter( 'post_class', 'gd_snippet_hide_no_review_text', 10, 3 );
Regards,
KiranApril 5, 2019 at 7:48 pm #478710Hi Kiran,
Thank you for the updated code.
However, it’s not working as expected, or how it worked in v1.
What this code seems to do is remove the *entire* listing from display (with the CSS). While that is a really cool idea, I like it and may put it to use as well 🙂 what I was looking for was simply to remove the display of the text “No Reviews” when a listing had no reviews (actually leaving the listing itself).
So just removing span.gd-list-rating-text when the listing had zero reviews.
Thanks again for your help here. Have a great day.
April 5, 2019 at 7:54 pm #478711Hi Kiran,
Thank you for the updated code.
However, it does not work as expected, or as it did in v1.
It seems as though when I place the code and related CSS, it removes the *entire* listing. While that is a cool feature option, I like it and may put it to use 🙂 the thing I was looking for was to simply remove the text “No Reviews” if the listing had no reviews (but leave the actual listing in place).
Basically remove – span.gd-list-rating-text – if the listing had no review, but leave it if it did have reviews.
Is this possible in v2 like we did in v1? and how would we do that?
Thanks for your help. Have a great day.
April 6, 2019 at 12:26 pm #478872Kiran’s snippet adds a class to the listing if there are no reviews, so that custom CSS can be used to hide any elements you don’t want to show if there are no reviews on the listing.
V1 snippets by and large will not work with V2.
In many cases common snippets have been integrated into new features for GDV2.
Generally speaking, we do not provide customization or support for customization here in the forum. We do strive to help with hiding features that are not needed, though, and most snippets or common CSS examples are limited to that domain, like Kiran’s snippet above. This is as opposed to changing how the functions of the software work, which is customization.
For more about customization, see this page:
https://wpgeodirectory.com/docs-v2/faq/customizing/However, if you want to change the way the software works because the feature is not available right now you can get a snippet from a GD Expert here:
https://geodirectoryexperts.com/April 6, 2019 at 1:30 pm #478899Hello Mitch,
In v2 you just need to little change in css to hide that text.
Use following style.
.gd-custom-no-review .geodir-post-rating .gd-list-rating-text { display: none; }
Thanks,
KiranApril 6, 2019 at 11:33 pm #478977Alex,
Yeah, I’ve noticed the snippet incompatibility between v1>v2. I’m kind of starting over on some of the things we had v1 do. Regardless, the improvements you guys have made in v2 easily overcome that inconvenience.
Kiran,
Thanks so much. Your help is greatly appreciated. The solid support is why I’ve continued to renew over the past several years. I hope that continues in the new v2 world.
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket