I have encountered a little snag using the the custom code you provided, it is working great within DIVI text module, if I try to use it within a DIVI field inside a module it doesn't get the post ID and the content is not shown. Not sure if we have reached the limit of Toolset/Divi integration - unless you still have some magic left in you 😉
This is the string I use in a Pricing Table module - in the price field - see screenshot