1

I currently have a number of custom metaboxes each look very similar to this:

/* -----------------------------------------------------------
# Team Information
----------------------------------------------------------- */
add_action( 'add_meta_boxes', 'team_information_metabox' );              
function team_information_metabox() 
    {   
        add_meta_box('team_information', 'Team Information', 'team_information_output', 'page', 'normal', 'high');
    }

function team_information_output( $post ) 
    {
    //so, dont ned to use esc_attr in front of get_post_meta
    $team_information_value=  get_post_meta($_GET['post'], 'team_information' , true ) ;
    wp_editor( $team_information_value, 'team-information', $settings = array('textarea_name'=>'team-information') );
    }


function save_team_information( $post_id ) 
{                   
    if (!empty($_POST['team-information']))
        {
        $data=$_POST['team-information'];
        update_post_meta($post_id, 'team_information', $data );
        }
}
add_action( 'save_post', 'save_team_information' );

And I am displaying them on a page like this:

$team_information_value = get_post_meta( get_the_ID(), 'team_information', true );

        // Checks and displays the retrieved value
        if( !empty( $team_information_value ) ) {
            echo $team_information_value;
        } else {
            echo 'Value Not Fount or Empty';

    }

For some reason, shortcodes are not working when I do this, how can I get shortcode functionality out of these?

1 Answer 1

1

Figured it out:

$team_information_value = get_post_meta( get_the_ID(), 'team_information', true );

    // Checks and displays the retrieved value
    if( !empty( $team_information_value ) ) {
        echo do_shortcode($team_information_value);
    } else {
        echo 'Value Not Fount or Empty';

}

Put the displayed value (in this case $team_information_value) within a do_shortcode();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.