Display list of tags as drop down menu or radio buttons in a meta box?

In my last project i had the same issue and i just used this: first get the list of tags to a var using the get_categories function by passing the right taxonomy like this: $args = array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘hide_empty’ => 0, ‘taxonomy’ => ‘post_tag’ ); $categories=get_categories($args); foreach($categories as $category) { … Read more

How to make multicheck for post/page meta box

The post metadata can store multiple values either as distinct entries in the postmeta table, or as one entry with the value as a serialized PHP array. The serialization may require less code, but the distinct entries allow faster querying later (“give me all posts that have at least option A of the multicheck checked”). … Read more

Removing Edit Permalink/View “Custom Post Type” areas

There is a filter get_sample_permalink_html that returns this area as a string. Here’s how you can use it: <?php add_filter(‘get_sample_permalink_html’, ‘perm’, ”,4); function perm($return, $id, $new_title, $new_slug){ global $post; if($post->post_type == ‘testimonials’) { $ret2 = preg_replace(‘/<span id=”edit-slug-buttons”>.*<\/span>|<span id=\’view-post-btn\’>.*<\/span>/i’, ”, $return); } return $ret2; } ?> Updated the code. Please check this. Updated Changed the double … Read more

Add comments meta fields to comments metabox on post edit screen

Unfortunately the hooks: manage_{$this->screen->id}_columns manage_{$this->screen->id}_sortable_columns manage_comments_custom_column are not available for the post-comments list table, constructed within the wp_ajax_get-comments call. That table consists only of two columns: author and comment. The data for author, avatar, email, url and IP is displayed in the first column. We can on the other hand use a hack like: add_filter( … Read more

How to make a meta box field a requirement

You can use Javascript to create a first-line convenience warning, but that is not a secure solution. You will need to interrupt the post save to truly create a required field. function req_meta_wpse_96762($data){ $allow_pending = false; if (isset($_POST[‘meta’])) { foreach ($_POST[‘meta’] as $v) { if (‘your_required_key’ === $v[‘key’] && !empty($v[‘value’])) { $allow_pending = true; } … Read more

How to activate “Description” metabox for menu item programmatically?

Remove the description from the user meta value managenav-menuscolumnshidden: add_filter( ‘manage_nav-menus_columns’, ‘enable_nav_menu_description_by_default’ ); function enable_nav_menu_description_by_default( $columns ) { $desc_key = ‘managenav-menuscolumnshidden’; $hidden = get_user_option( $desc_key ); $user_id = wp_get_current_user()->ID; if ( ! $hidden ) { update_user_option( $user_id, $desc_key, array ( 0 => ‘link-target’, 1 => ‘css-classes’, 2 => ‘xfn’ ) ); } elseif ( FALSE … Read more

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