Simply check that the rating is not empty before printing the markup you wish to make conditional:
<?php
$rating = get_average_listing_rating( $post->ID, 1 );
if ( ! empty( $rating ) ) { ?>
<span class="js-average-rating"><i class="star"></i> <?php echo $rating; ?></span>
<?php } ?>
Without seeing this in context, it’s possible you need the outer span to maintain alignment or something else. If so, just move what you need outside of the condition test.
Related Posts:
- Extending Genericons in WordPress
- Remove apple-touch-icon link generated by WordPress
- How to edit original wordpress HTML source code and add icon?
- Font Awesome Icons only squares
- Expected an identifier and instead saw ‘
- social icons not showing
- Shown icon if old
- What is the `post-status` icon handle when using `@wordpress/icons`?
- Disable emojicons introduced with WP 4.2
- how to change default icon of custom plugin?
- Replacing Icons in the Dashboard
- How do I set up the defualt page icon for admin menu?
- How to use a WordPress’ existing admin icon?
- How can I make my Admin Icon SVG color correctly? [closed]
- Programmatically Add Font-Awesome Icons to Category Widget
- Add custom SVG icons to Social Icon MENU in WordPress Twenty Seventeen Child Theme
- Why could I not change the icon of the default Add media button that I added into the toolbar of TinyMCE?
- How to display an icon when a new post is published and then remove it when a specific time past?
- How to get Menu Navigation Labels to output HTML
- How to add iOS & fav icons to the theme?
- How can I use a different default admin menu icon for custom post type?
- WordPress native “playlist” shortcode. Next and Prev there are but with no icons. How to fix?
- How do I remove the eye icon that shows visibility on login screen and reset password screen
- How can a default site icon be set in customizer?
- Add 32×32 icon to custom post type index page
- Plugin that inserts favicon next to links
- Icon font not working on subdomains of multisite
- How to show Home Page link in WordPress Menu and how to add an icon to this?
- Compact pingback list with favicons
- Font awesome Icon HTML in widgets disappear on save
- Font Awesome Icons Won’t Work
- How do i add edit shortcut icon in wordpress without using selective refresh
- Location of theme options page menu icon
- custom admin thumbnail for videos, not getting post’s id?
- How to add an RSS logo to my blogs header?
- How can I replace the text at the top of a custom column into a icon?
- Add icon/badge next to posttitle of specific category
- CSS to remove “comments count” icon from main page [closed]
- Jetpack social icons in other places on site
- How to insert icon in site title
- change video icons to selected thumbnail?
- Change via CSS the color of social menu icons
- Set Site Icon programmatically (eg. using `wp cli`)
- How to Add Custom New Published Post Counter Icon on Top of the WordPress Site [closed]
- Dashicons and Pseudo :before
- Xili language plugin not showing language flag [closed]
- How to Change custom post type Dashicon Color
- Display an icon with get_post_meta?
- How to edit the default icon of Add Media button?
- Theming Using Bootstrap Glyphicons and WordPress Dashicons
- Get custom classes in WordPress Navigation Menu
- wp_trim_words strips dashicons
- Icons are missing from Visual Editor
- Can wp_get_image_editor convert to icon?
- Icon over thumbnail according to post format
- Custom Fields Question
- Change the search icon in twenty fourteen
- how to add home icon instead of text in wordpress menu
- Replacing WordPress Icons (menu,icons32, etc)?
- How to add RSS Icon/link as a widget?
- Custom Icon for Plugin
- WordPress Favicon not Working For Images/Videos/PDFs
- Hover a css icon width other color inside wp_get_attachment_image
- Widget Style – Icon Type
- Export / import
- How to remove the icons corresponding to “by” (author) and “date” from posts?
- Placing Lock Icon on WooCommmerce “Place Order” Checkout Button (WordPress ‘ignoring’ Changes…)
- SVG icons in Twenty Nineteen
- Swap SVG icons in child themes
- Need to replace some text string on a title
- jQuery for Fade Preload Causes My Site Favicon to Disappear from Tab of Browser
- Custom Icon assigned to menu items not working for multi-site networks
- image on homepage disappeared due to change of permalink name
- Where to place a svg chevron down in my custom walker?
- Taxonomy Category Icon on index page
- How to reduce the image size inside an icon? [closed]
- How to display an icon when a new post is published and then remove it when a specific time past?
- Issue on adding Icons to Custom Post Type
- how to add fa fa icons customize menu using wp_nav_menu function?
- Why plugin’s icon for the menu not found?
- How To Add Class To Style Search Box
- How to replace plugin icon?
- Plugin Icon does not work correctly
- SVG showing only in square ratio (using elementor) [closed]
- Icon not shown in Dropdown menus in Twenty Seventeen Theme
- How to change mobile menu (toggle) icon in WordPress – Full Site Editing?