Skip to content

Instantly share code, notes, and snippets.

@turtlepod
Created September 12, 2017 02:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save turtlepod/57f11cd7fbf999df394872cf751d4ab0 to your computer and use it in GitHub Desktop.
Save turtlepod/57f11cd7fbf999df394872cf751d4ab0 to your computer and use it in GitHub Desktop.
Remove Rating Display if No Rating Exists Yet in Listify Theme.
<?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