最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - CMB2 Output Select Box Chosen Option

programmeradmin1浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论