no review php

This topic contains 7 replies, has 4 voices, and was last updated by  Mitch Canton 5 years, 7 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #478429

    Mitch Canton
    Expired Member
    Post count: 167

    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.

    #478454

    Kor
    Moderator
    Post count: 16516

    Hi Mitch Canton,

    Thanks for your post. Will forward this to a developer for further assistance.

    #478525

    Kiran
    Moderator
    Post count: 7069

    Hello 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,
    Kiran

    #478710

    Mitch Canton
    Expired Member
    Post count: 167

    Hi 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.

    #478711

    Mitch Canton
    Expired Member
    Post count: 167

    Hi 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.

    #478872

    Alex Rollin
    Moderator
    Post count: 27815

    Kiran’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/

    https://wpgeodirectory.com/support-policy/

    #478899

    Kiran
    Moderator
    Post count: 7069

    Hello 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,
    Kiran

    #478977

    Mitch Canton
    Expired Member
    Post count: 167

    Alex,

    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.

Viewing 8 posts - 1 through 8 (of 8 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