1

I'm trying to take away the option to have sharing options on 'pages' (but leave on posts).

So I have a function to make sure the sharing option is always no on pages

function page_disable_share($post_id)
{
if ( 'page' != get_post_type() )
    return;

    update_post_meta($post_id, "sharing_disabled", 1);
}
add_action('save_post', 'page_disable_share');

But I'd rather not have the meta box there at all, it might confuse the user if they tick it and it always unticks itself.

function page_remove_share()
{
    remove_meta_box( 'sharing_meta' , 'page' , 'normal' ); 
}
add_action('admin_menu' , 'page_remove_share');

Bu that's not working. Maybe JetPack is getting hooked in after 'admin_menu'? I tried other hooks (http://codex.wordpress.org/Plugin_API/Action_Reference) but none work. Any ideas?

1

Use the add_meta_boxes action with a very low priority, so:

function page_remove_share() {
    remove_meta_box( 'sharing_meta' , 'page' , 'advanced' ); 
}
add_action( 'add_meta_boxes', 'page_remove_share', 99 );

I think that should work.

| improve this answer | |
  • It had so much potential, but unfortunately it doesn't work. – deadlyhifi Sep 28 '11 at 12:57
  • I had a look how it was hooked in in the plugin itself. The answer is: remove_meta_box( 'sharing_meta', 'page', 'advanced' ); The only difference is that the context is 'advanced'. I can't answer my own question because my rep isn't high enough. – deadlyhifi Sep 28 '11 at 13:06
  • Ok updated it :) – Joost de Valk Sep 28 '11 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.