For a number of reasons, especially Testing, it would be very valuable to understand how you are using Custom Fields. Here are some questions that would help me:
- Are you referring to a Post’s or Page’s Custom Fields? Some people refer to the Site Title as a Custom Field. And others refer to Attachment metadata as Custom fields.
- How are you accessing the Custom Fields? For example, using a Shortcode, directly coding PHP in a Theme, or through some built-in mechanism in a Theme or Plugin?
- Are you just looking to have the Shortcode you place in a Custom Field “expanded” only when it is retrieved from the WordPress database? Or do you need it expanded within the WordPress database? For example, if a Query is generated to search for a value of a Custom Field, that might require different handling by my plugin than if you were simply displaying a Custom Field value on a Page or Post.
I’m out of the office for the rest of the day today, but I’ll be back this evening, and will be working on this tomorrow morning. I have found what appears to be the right Filter to do this for Page and Post Custom Fields being displayed and compared, but perhaps not Queried. Next step is to be sure it works the way you want to use Custom Fields, and how I suspect others might.