This members-only tutorial provides the steps to define a custom function that takes in a post type, custom field name, and the corresponding custom field value as parameters and returns either true (1) or false ('') depending on whether at least one of the entries of the given post type has the given value for the given custom field.

Sample Use Case: Let's say you have an event CPT with an associated radio button type of custom field called event_free_ticket that can either have a value of yes or no. Now you want to display 3 events in a Repeater that is inside a Section and output the Section only if at least one of the three events have event_free_ticket set to yes.

Add the custom function given below as a Code Snippet and use the built-in Dynamic Data condition's PHP Function Return value on the Section while specifying the function name and the arguments.

Code Snippet title: [Function] At least one entry has specific custom field value


This is a premium members-only content.

To view the rest of the content, please sign up for membership ($47/month or $399 one-time).

Already a member? Log in below or here.

Need help implementing a tutorial in your site or want to hire me for custom work?


Find the article helpful and wish to donate?



You need to be logged in to view and post comments.
Not a member yet? Join here.
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
%d bloggers like this: