I am trying to build a plugin for showing a pie diagram based on the number of those categories which have maximum posts. This diagram is a meta box in post editing page. Here is my source of inspiration: jquery charts
Most of the way the function works is same but I added some hooks to add it into meta box.
Here is my code:
add_action( 'add_meta_boxes', 'category_meta_box_add' );
function category_meta_box_add() {
add_meta_box( 'my-meta-box-id', 'Category by Percentage', 'categories', 'post', 'normal', 'high' ); }
function categories($atts,$content = '') { } //full function is defined in link above
add_shortcode('mycategories', 'categories');
echo do_shortcode('[mycategories]');
This plugin on installing shows meta box without data, also gives error:
The plugin generated 721 characters of unexpected output during
activation. If you notice âheaders already sentâ messages, problems
with syndication feeds or other issues, try deactivating or removing
this plugin.
How to resolve this?
Thanks
Full plugin here
The problem might be because of this line:
It should not stand alone like this in the plugin file, because this will show up before the headers are sent out. I guess you added this line just to check the output? Try to remove this line or encapsulate it with a relevant function. You could instead add the shortcode
[mycategories]
into the content of some post/page to test it.You could replace this line
with
and add this function:
to display the graph inside the metabox.