Skip to content

Instantly share code, notes, and snippets.

@joshuadavidnelson
Last active April 5, 2023 21:06
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save joshuadavidnelson/334da35b5ef7e345d51a to your computer and use it in GitHub Desktop.
Add shortcode support to custom field output
<?php
/**
* Apply shortcodes to custom field output
*
* @author Joshua David Nelson, josh@joshuadnelson.com
*/
$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>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment