Apply the_content filter to a custom field with multiple values

All you need to do use apply_filters.

foreach ($video as $vid) {
    echo '<li>'.apply_filters('the_content',$vid).'</li>';
}

It may be more efficient to concatenate a string and then run the filter on the whole thing.

$lis="";
foreach ($video as $vid) {
    $lis .= '<li>'.$vid.'</li>';
}
echo apply_filters('the_content',$lis);

I haven’t benchmarked the one versus the other but given that the latter calls the filter once and the former many times, I’d bet on the latter.

Leave a Comment