How to Use WordPress Color Picker API in Custom Post Type Metabox

I’ve created a metabox once with color picker. You need to include color picker style and script in your admin_enqueue_scripts hook, and then initialize it with $(‘.color-picker’).wpColorPicker(); From my gist: <?php add_action( ‘admin_enqueue_scripts’, ‘mytheme_backend_scripts’); if ( ! function_exists( ‘mytheme_backend_scripts’ ) ){ function mytheme_backend_scripts($hook) { wp_enqueue_media(); wp_enqueue_style( ‘wp-color-picker’); wp_enqueue_script( ‘wp-color-picker’); } } add_action( ‘add_meta_boxes’, ‘mytheme_add_meta_box’ ); … Read more

Move excerpt to always be directly below post content in admin

The reason why your code doesn’t work is most likely that you’ve ordered your metaboxes before, and the that order has been saved into the meta-box-order_page meta value. This overrides the default setup. Here’s an example of the meta-box-order_post meta value: a:3:{ s:4:”side”; s:61:”submitdiv,formatdiv,categorydiv,tagsdiv-post_tag,postimagediv”; s:6:”normal”; s:96:”revisionsdiv,postexcerpt,trackbacksdiv,postcustom, commentstatusdiv,commentsdiv,slugdiv,authordiv”; s:8:”advanced”; s:0:””; } Here I’ve just reformatted the … Read more

upload image in a meta box

You may want to take a look at Steve Taylors plugin and his approach here Dominik “ocean90” Schilling – the author of the (new in 3.5) media library, has a GitHub repository where he shows off some demos. In short, you might not be able to implement a drag&drop style media uploader in a meta … Read more

Add custom option to Standard Page Attributes Meta Box

Unfortunately not. The only way is to deregister the metabox, and then re-register it, supplying your own callback function which mimics the original metabox, but with your alterations (making sure the names of the inputs do not change). This method is outlined in these posts: custom post type taxonomies UI radiobuttons not checkboxes Custom-Taxonomy as … Read more

Add script to footer – on post editor

Hook into ‘admin_footer-post-new.php’ and ‘admin_footer-post.php’, check the global variable $post_type: add_action( ‘admin_footer-post-new.php’, ‘wpse_73692_script’ ); add_action( ‘admin_footer-post.php’, ‘wpse_73692_script’ ); function wpse_73692_script() { if ( ‘post’ !== $GLOBALS[‘post_type’] ) return; ?> <script>alert( ‘<?php echo $GLOBALS[‘post_type’];?>’ );</script> <?php }

How to remove a metabox from menu editor page?

By inspecting the file /wp-admin/nav-menus.php we can see that these meta-boxes: are rendered with: <?php do_meta_boxes( ‘nav-menus’, ‘side’, null ); ?> The file /wp-admin/includes/nav-menu.php contains the corresponding add_meta_box() calls and from that we can construct the relevant removal code: function custom_remove() { remove_meta_box(‘nav-menu-theme-locations’, ‘nav-menus’, ‘side’); remove_meta_box(‘add-custom-links’, ‘nav-menus’, ‘side’); remove_meta_box(‘add-post’, ‘nav-menus’, ‘side’); remove_meta_box(‘add-page’, ‘nav-menus’, ‘side’); remove_meta_box(‘add-category’, … Read more

How to add meta box to plugin admin page?

add_meta_boxes is for adding meta boxes to post types. What you’re looking for is the Settings API. In your add_menu_page function you are calling a function named test_plugin_admin_options. This function will hold the content of your options page. You will also need to register your settings with register_setting(). //add menu page add_action(‘admin_menu’, ‘test’); function test(){ … Read more

Find callback function for custom taxonomy metabox

The callback you need for non-hierarchical taxonomies is post_tags_meta_box. The callback you need for hierarchical taxonomies is post_categories_meta_box. For your example, the code would be: /* Remove movies metabox from sidepanel */ function hide_metabox(){ remove_meta_box( ‘tagsdiv-movies’, ‘your-post-type’ , ‘side’ ); } add_action( ‘admin_menu’ , ‘hide_metabox’ ); /* Add back movies metabox, but in post area … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)