admin管理员组

文章数量:1431420

I have the following code for a metabox which allows the user to select a post category but I cant seem to ouput the chosen option on the front end. Any ideas ?

Heres what I have so far :

// Choose Category For Posts
    $cmb->add_field( array(
        'name'    => esc_html__( 'Category', 'majestica' ),
        'desc'    => esc_html__( 'Category of Posts to Display. If using one of the templates that displays a number of posts.', 'majestica' ),
        'id'      => 'majestica_posts_category',
        'taxonomy'       => 'category', //Enter Taxonomy Slug
        'type'           => 'taxonomy_select',
    ) );

And on the front end :

$categoryname = get_post_meta( get_the_ID(), 'majestica_posts_category', true );
echo $categoryname;

It doesnt display anything, I simply want it to echo out the chosen category.

Please help.

本文标签: pluginsCMB2 Output Select Box Chosen Option