I know there’s a filter get_post_content that I can hook into, but that only seems to work with get_post_meta, I need to filter individual values of get_post_custom() by checking if the metadata key matches like:
function filter_custom($meta)
{
foreach($meta as $k => $v)
{
if ($k === 'some_key') return $v . 'filtered';
}
}
add_filter('get_post_custom', 'filter_custom');
Is there a hook for this? if not what would be the best way to accomplish it?
The quickest way to answer this question is to follow the code. See
get_post_custom
in Codex. Scroll down to Source Code section:There we’ll see that
get_post_custom
callsget_post_meta
, which then callsget_metadata
, which points us to:there we’ll finally see the available filter:
in this case,
post
is the$meta_type
, so our filter isget_post_metadata