Action hook on Edit custom post type?

register_post_type() has a registration option called ‘register_meta_box_cb’. Set that to a valid callback and it will call that function only when it is compiling the meta boxes for that post type’s edit screen. Something like this: register_post_type( ‘foo’, array( ‘public’ => true, ‘label’ => ‘foo’, ‘register_meta_box_cb’ => ‘bar’, )); function bar(){ add_meta_box(‘blah’, ‘blah’, /* etc … Read more

WP_Query with checkbox meta_query

Take a look at the codex for a better understanding of queries of custom fields but it should look something like this: $subjects_array = explode(“_”, $_GET[“subjects”]); $args = array( ‘post_status’ => ‘publish’, ‘post_type’ => ‘any’, ‘meta_query’ => array( array( ‘key’ => ‘field_name’, ‘value’ => $subjects_array, ‘compare’ => ‘IN’ ) ) ); $query = new WP_Query($args);

Remove unusable metaboxes in nav menu management screen

There are two important global variables in wp-admin/nav-menus.php: $nav_menus is an array of all available menus, filled with wp_get_nav_menus(). $wp_meta_boxes[‘nav-menus’] is an array of all available metaboxes for this screen. We can hook into admin_head-nav-menus.php, an action called after the first variable has been set up, and change the second variable: add_action( ‘admin_head-nav-menus.php’, ‘t5_hide_dead_menu_metaboxes’ ); … Read more

How to add a new tab to page editor

I remembered that once I done this, yesterday I found where, but that code was… bad. So today I little improved it and I’m going to share. Before I want to explain what I do. First of all, there are 3 main things to do: Add the tab title beside the standard 2 Add something … Read more

Custom Post Type – Taxonomy Dropdown Menu?

This is how I did this. <?php $tax = get_object_taxonomies(‘TAXONOMY_NAME’); $taxterms = get_terms( $tax, ‘orderby=count&offset=1&hide_empty=0&fields=all’ ); ?> <select name=”tax” id=’tax’> <option value=”” <?php if (!count( $names )) echo “selected”;?>>Select Term</option> <?php foreach ( $taxterms as $term ) { echo ‘<option value=”‘ . $term->slug . ‘” selected>’ . $term->name . ‘</option>’,”\n”; } ?> </select>

Can I force a metabox to be in one column?

If you want the meta box to appear below the content area, use the context parameter ‘normal’. See Function Reference/add meta box – Parameters. Initially, your meta box should only go to the side bar if the context parameter is set to ‘side’. As far as making it impossible for the user to drag it … Read more

Custom taxonomy hide meta box but show in menu

You’re looking for the meta_box_cb argument. $args = array( ‘hierarchical’ => true, ‘labels’ => $labels, ‘show_ui’ => false, ‘show_admin_column’ => false, ‘show_in_menu’ => true, ‘show_in_nav_menus’ => true, ‘query_var’ => true, ‘rewrite’ => array( ‘slug’ => ‘wheel’ ), ‘meta_box_cb’ => false, ); register_taxonomy( ‘wheel’, array( ‘product’ ), $args ); You can also define a custom callback … Read more

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