Title: {No_Notes} Not Working
Last modified: August 22, 2016

---

# {No_Notes} Not Working

 *  Resolved [danbru](https://wordpress.org/support/users/danbru/)
 * (@danbru)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/no_notes-not-working/)
 * I got my {has_notes} working fine, but what am I missing in my {no_notes} code?
 * Appreciate your help!
 *     ```
       function em_event_output_condition_filter($replacement, $condition, $match, $EM_Event){
       // Checks for has_notes conditional
       if(is_object($EM_Event) && preg_match(‘/^has_(notes)$/’, $condition, $matches)){
       if(isset($EM_Event->$matches[1]) && !empty($EM_Event->$matches[1])){
       $replacement = preg_replace(“/\{\/?$condition\}/”, ”, $match);
       }else{
       $replacement = ”;
       }
       }
       // Checks for no_notes conditional
       if(is_object($EM_Event) && preg_match(‘/^no_(notes)$/’, $condition, $matches)){
       if( !array_key_exists($matches[1], $EM_Event->event_attributes) ){
       $replacement = preg_replace(“/\{\/?$condition\}/”, ”, $match);
       }else{
       $replacement = ”;
       }
       }
       return $replacement;
       }
       add_filter(‘em_event_output_condition’, ‘em_event_output_condition_filter’, 1, 4);
       ```
   
 * [https://wordpress.org/plugins/events-manager/](https://wordpress.org/plugins/events-manager/)

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

 *  [John Russell](https://wordpress.org/support/users/laubsterboy/)
 * (@laubsterboy)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/no_notes-not-working/#post-5691948)
 * I’ve made a few changes to your no_notes code and tested it to be sure that it
   works.
 *     ```
       function em_event_output_condition_filter($replacement, $condition, $match, $EM_Event) {
       	// Checks for has_notes conditional
       	if (is_object($EM_Event) && preg_match('/^has_(notes)$/', $condition, $matches)) {
       		if (isset($EM_Event->$matches[1]) && !empty($EM_Event->$matches[1])) {
       			$replacement = preg_replace("/\{\/?$condition\}/", '', $match);
       		} else {
       			$replacement = '';
       		}
       	}
   
       	// Checks for no_notes conditional
       	if (is_object($EM_Event) && preg_match('/^no_(notes)$/', $condition, $matches)) {
       		if (!isset($EM_Event->$matches[1]) || empty($EM_Event->$matches[1])) {
       			$replacement = preg_replace("/\{\/?$condition\}/", '', $match);
       		} else {
       			$replacement = '';
       		}
       	}
       	return $replacement;
       }
       add_filter('em_event_output_condition', 'em_event_output_condition_filter', 1, 4);
       ```
   
 * This is an example of how it could be used:
 *     ```
       {has_notes} This text will show up if notes have been filled out: #_EVENTNOTES {/has_notes}
   
       {no_notes} This text will only show up if notes is empty. {/no_notes}
       ```
   
 *  Thread Starter [danbru](https://wordpress.org/support/users/danbru/)
 * (@danbru)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/no_notes-not-working/#post-5691950)
 * Thank you for your time! That works!
 * Need this for locations too, so I changed all the “event”‘s to “location” and
   it’s not working for locations. Could you help there too?
 *     ```
       /* ========== EVENTS MANAGER – CUSTOM CODE ========== */
       function em_event_output_condition_filter($replacement, $condition, $match, $EM_Event) {
       	// Checks for Event {has_notes} conditional
       	if (is_object($EM_Event) && preg_match('/^has_(notes)$/', $condition, $matches)) {
       		if (isset($EM_Event->$matches[1]) && !empty($EM_Event->$matches[1])) {
       			$replacement = preg_replace("/\{\/?$condition\}/", '', $match);
       		} else {
       			$replacement = '';
       		}
       	}
   
       	// Checks for Event {no_notes} conditional
       	if (is_object($EM_Event) && preg_match('/^no_(notes)$/', $condition, $matches)) {
       		if (!isset($EM_Event->$matches[1]) || empty($EM_Event->$matches[1])) {
       			$replacement = preg_replace("/\{\/?$condition\}/", '', $match);
       		} else {
       			$replacement = '';
       		}
       	}
       	return $replacement;
       }
       add_filter('em_event_output_condition', 'em_event_output_condition_filter', 1, 4);
   
       function em_location_output_condition_filter($replacement, $condition, $match, $EM_Location) {
       	// Checks for Location {has_notes} conditional
       	if (is_object($EM_Location) && preg_match('/^has_(notes)$/', $condition, $matches)) {
       		if (isset($EM_Location->$matches[1]) && !empty($EM_Location->$matches[1])) {
       			$replacement = preg_replace("/\{\/?$condition\}/", '', $match);
       		} else {
       			$replacement = '';
       		}
       	}
   
       	// Checks for Location {no_notes} conditional
       	if (is_object($EM_Location) && preg_match('/^no_(notes)$/', $condition, $matches)) {
       		if (!isset($EM_Location->$matches[1]) || empty($EM_Location->$matches[1])) {
       			$replacement = preg_replace("/\{\/?$condition\}/", '', $match);
       		} else {
       			$replacement = '';
       		}
       	}
       	return $replacement;
       }
       add_filter('em_location_output_condition', 'em_location_output_condition_filter', 1, 4);
       ```
   
 *  [John Russell](https://wordpress.org/support/users/laubsterboy/)
 * (@laubsterboy)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/no_notes-not-working/#post-5691951)
 * No problem. This can be made to work for locations as well, but the $EM_Location
   object doesn’t have a ‘notes’ property. Instead it’s called ‘post_content’, yet
   represents the same field. Due to the naming differences you either need to change
   the conditional to be {has_post_content} {/has_post_content} {no_post_content}{/
   no_post_content}, or keep the same naming convention (for consistency sake between
   events and locations) and hardcode the post_content property into the conditional
   function.
 * I’ve added the functioning (and tested) code for {has_notes} and {no_notes} for
   locations below:
 *     ```
       function em_location_output_condition_filter($replacement, $condition, $match, $EM_Location) {
       	// Checks for has_notes conditional
       	if (is_object($EM_Location) && preg_match('/^has_(notes)$/', $condition, $matches)) {
       		if (isset($EM_Location->post_content) && !empty($EM_Location->post_content)) {
       			$replacement = preg_replace("/\{\/?$condition\}/", '', $match);
       		} else {
       			$replacement = '';
       		}
       	}
   
       	// Checks for no_notes conditional
       	if (is_object($EM_Location) && preg_match('/^no_(notes)$/', $condition, $matches)) {
       		if (!isset($EM_Location->post_content) || empty($EM_Location->post_content)) {
       			$replacement = preg_replace("/\{\/?$condition\}/", '', $match);
       		} else {
       			$replacement = '';
       		}
       	}
       	return $replacement;
       }
       add_filter('em_location_output_condition', 'em_location_output_condition_filter', 1, 4);
       ```
   
 *  Thread Starter [danbru](https://wordpress.org/support/users/danbru/)
 * (@danbru)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/no_notes-not-working/#post-5691952)
 * Thanks!
 * I really appreciate your help!

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

The topic ‘{No_Notes} Not Working’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=3550347)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [danbru](https://wordpress.org/support/users/danbru/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/no_notes-not-working/#post-5691952)
 * Status: resolved