Created
September 12, 2017 02:01
-
-
Save turtlepod/57f11cd7fbf999df394872cf751d4ab0 to your computer and use it in GitHub Desktop.
Remove Rating Display if No Rating Exists Yet in Listify Theme.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Remove Rating Display if No Rating Exists Yet | |
* | |
* @link https://secure.helpscout.net/conversation/425117562/121662/ | |
*/ | |
add_action( 'init', function() { | |
// Remove Rating in Card if Empty. | |
add_filter( 'listify_get_listing_to_array', function( $data ) { | |
if ( ! $data['reviews']['count'] ) { | |
$data['cardDisplay']['rating'] = false; | |
} | |
return $data; | |
} ); | |
// Remove In Single Listing Hero (Only for WPJM Reviews). | |
add_action( 'template_redirect', function() { | |
if ( is_singular( 'job_listing' ) && function_exists( 'wpjmr_get_reviews_count' ) ) { | |
$count = wpjmr_get_reviews_count( get_queried_object_id() ); | |
if ( ! $count ) { | |
remove_action( 'single_job_listing_meta_after', 'listify_the_listing_rating' ); | |
} | |
} | |
} ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment