Filter the output of a custom field to support shortcodes within the field.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Apply shortcodes to custom field output | |
* | |
* @author Joshua David Nelson, [email protected] | |
*/ | |
$custom_field_output = 'some text with a [shortcode]'; | |
add_filter( 'custom_field', 'do_shortcode' ); | |
$custom_field_output = apply_filters( 'custom_field', $custom_field_output ); | |
echo '<div class="custom-field">' . wpautop( $custom_field_output ) . '</div>'; |
Source: https://gist.github.com/joshuadavidnelson/334da35b5ef7e345d51a
Tags: custom field, shortcode