3

I'm trying to add some metabox to my custom post type. So I add this:

add_meta_box(
    'my_custom_meta_box_id', 
    'My-meta-box-title',
    'my_custom_meta_box_callback', 
    'my-custom-post-type', 
    'side', 
    'default'
);

So the meta-box keep showing at bottom left. What could cause that problem?

4
  • 6
    The metabox was added in a different context before? If so, the metabox position is probably saved as user option and so keep showing on main column, even if now it is added on the sidebar. Try to create another test user, log in with this new user and metabox should appear in sidebar. If my guess is correct, for the user the view sidebar on the left, simply move it manually on the right.
    – gmazzap
    Sep 20, 2014 at 18:24
  • Once this function is ran, does it need to be left in the code? Actually manually moving is pretty good! Didn't know about that! Thanks! Sep 20, 2014 at 18:34
  • With the function in OP new users or existing users had bever vieved the metabox before, will se the metabox on the sidebar. If you are the only and unique user of the site, move it where you want, and don't care about that.
    – gmazzap
    Sep 20, 2014 at 18:36
  • Thank you very much. Just that behavior is strange.First it was side and then somehow it went bottom. Now I know. Thanks mate, case closed. Sep 20, 2014 at 19:11

1 Answer 1

2

This might be caused because you have tried to move your custom meta box to some place and Wordpress respects the user's ordering/positioning of these boxes. You can do as gmazzap has told because this will create a new user with blank preferences.

Or you can login to your database, find DBPREFIX_usermeta (DBPREFIX is your database prefix) and find related database entries. In my case:

db entries for custom ordering of user

You can see meta-box-order_PLUGINNAME (where it is your plugin's name) and screen_layout_PLUGINNAME. When I removed these entries, the problem was gone.

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.