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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745558100a4632940.html
评论列表(0条)