Title: Hide Empty Property Details
Last modified: February 1, 2018

---

# Hide Empty Property Details

 *  [withacause](https://wordpress.org/support/users/withacause/)
 * (@withacause)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/hide-empty-property-details/)
 * Hi there,
 * I used this code in my child theme functions.php on my site and it worked great
   but it suddenly stopped working for some reason. Thoughts?
 * Code was supposed to hide empty fields in the [property_details] shortcode for
   single listing page. So, for example, if Basement isn’t filled in, it isn’t output
   in the shortcode.
 * [https://github.com/copyblogger/agentpress-listings/issues/6](https://github.com/copyblogger/agentpress-listings/issues/6)
 * Any thoughts on how to get this working again?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Support [Nick C](https://wordpress.org/support/users/modernnerd/)
 * (@modernnerd)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/hide-empty-property-details/#post-9934849)
 * [@withacause](https://wordpress.org/support/users/withacause/) That code is still
   working for me if I replace the `property_details_shortcode()` function in the
   AgentPress Listings plugin.
 * Or you can use this version in your theme’s `functions.php`:
 *     ```
       add_shortcode( 'property_details_new', 'property_details_shortcode' );
       function property_details_shortcode( $atts ) {
   
       	global $post, $_agentpress_listings;
   
       	$output = '';
   
       	$output .= '<div class="property-details">';
   
       	$output .= '<div class="property-details-col1">';
       		foreach ( (array) $_agentpress_listings->property_details['col1'] as $label => $key ) {
       			$value = get_post_meta($post->ID, $key, true);
       			if ( !empty( $value ) ) {
       				$output .= sprintf( '<b>%s</b> %s<br />', esc_html( $label ), esc_html( get_post_meta($post->ID, $key, true) ) );
       			}
       		}
       	$output .= '</div><div class="property-details-col2">';
       		foreach ( (array) $_agentpress_listings->property_details['col2'] as $label => $key ) {
       			$value = get_post_meta($post->ID, $key, true);
       			if ( !empty( $value ) ) {
       				$output .= sprintf( '<b>%s</b> %s<br />', esc_html( $label ), esc_html( get_post_meta($post->ID, $key, true) ) );
       			}
       		}
       	$output .= '</div><div class="clear">';
       		$output .= sprintf( '<p><b>%s</b><br /> %s</p></div>', __( 'Additional Features:', 'apl' ), get_the_term_list( $post->ID, 'features', '', ', ', '' ) );
   
       	$output .= '</div>';
   
       	return $output;
   
       }
       ```
   
 * You will then need to use `[property_details_new]` for your shortcode instead
   of `[property_details]`.
 *  Thread Starter [withacause](https://wordpress.org/support/users/withacause/)
 * (@withacause)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/hide-empty-property-details/#post-9934945)
 * Thank you, Nick! Once I placed the code in the plugin instead of the theme functions
   it worked. Thank yoU!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Hide Empty Property Details’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/agentpress-listings_46515d.svg)
 * [AgentPress Listings](https://wordpress.org/plugins/agentpress-listings/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/agentpress-listings/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/agentpress-listings/)
 * [Active Topics](https://wordpress.org/support/plugin/agentpress-listings/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/agentpress-listings/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/agentpress-listings/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [withacause](https://wordpress.org/support/users/withacause/)
 * Last activity: [8 years, 3 months ago](https://wordpress.org/support/topic/hide-empty-property-details/#post-9934945)
 * Status: not resolved