Display a Default Message When Merge Tags Are Not Replaced

Code

Filename: gppcmt-default-message.php

<?php
/**
 * Gravity Wiz // Post Content Merge Tags // Display a Default Message When Merge Tags Are Not Replaced
 * https://gravitywiz.com/documentation/gravity-forms-post-content-merge-tags/
 */
add_filter( 'the_content', function( $content ) {
	if ( GFCommon::has_merge_tag( $content ) ) {
		$content = 'Default message.';
	}
	return $content;
} );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.