Remove Empty Label Segments by Delimiter
Let’s say you have a Populate-Anything-populated field that has a Custom Value template configured like this: {post:post_title} – {post:post_excerpt}
This would populate the post title and post excerpt for each populated choice; however, some posts may not have an excerpt. This snippet will split the string up by the delimiter (in this case, ” – “) and remove any empty segments so the final result may look like “Post Title – Post Excerpt” or, if there is no excerpt, just “Post Title”.
Instructions
See “Where do I put snippets?” in our documentation for installation instructions.
Code
Filename: gppa-remove-empty-label-segments.php