Custom column for changing post status via ajax

here you go: <?php /* Plugin Name: ajaxed-status Plugin URI: http://en.bainternet.info Description: answer to : Custom column for changing post status via ajax http://wordpress.stackexchange.com/questions/33442/custom-column-for-changing-post-status-via-ajax Version: 1.0 Author: Bainternet Author URI: http://en.bainternet.info */ if ( !class_exists(‘ajaxed_status’)){ class ajaxed_status { //constarctor public function __construct() { global $pagenow,$typenow; //&& $typenow ==’page’ if (is_admin() && $pagenow==’edit.php’){ add_filter(‘admin_footer’,array($this,’insert_ajax_status_script’)); } add_filter( … Read more

Custom columns on edit-tags.php main page

You can do this by hooking into the ‘taxonomy’_edit_form and edited_’taxonomy’ actions. add_action(‘taxonomy_edit_form’, ‘foo_render_extra_fields’); function foo_render_extra_fields(){ $term_id = $_GET[‘tag_ID’]; $term = get_term_by(‘id’, $term_id, ‘taxonomy’); $meta = get_option(“taxonomy_{$term_id}”); //Insert HTML and form elements here } add_action(‘edited_taxonomy’, ‘bar_save_extra_fields’, 10, 2); function bar_save_extra_fields($term_id){ $form_field_1 = $_REQUEST[‘field-name-1’]; $form_field_2 = $_REQUEST[‘field-name-2’]; $meta[‘key_value_1’] = $form_field_1; $meta[‘key_value_2’] = $form_field_2; update_option(“taxonomy_{$term_id}”, $meta); } … Read more

Adding Category/Tag/Taxonomy Support to Images/Media

Here’s how I recently added a custom taxonomy to the media library as a sortable column: // Add a new column add_filter(‘manage_media_columns’, ‘add_topic_column’); function add_topic_column($posts_columns) { $posts_columns[‘att_topic’] = _x(‘Topic’, ‘column name’); return $posts_columns; } // Register the column as sortable function topic_column_register_sortable( $columns ) { $columns[‘att_topic’] = ‘att_topic’; return $columns; } add_filter( ‘manage_upload_sortable_columns’, ‘topic_column_register_sortable’ ); … Read more

Make custom column sortable

Make sure to change MY_POST_TYPE, MY_CUSTOM_COLUMN and MY_META_KEY to the actual values. First, add your custom column. Unset the date and set it again to keep it in the last column. You can skip this step. <?php function my_manage_MY_POST_TYPE_columns( $columns ) { // save date to the variable $date = $columns[‘date’]; // unset the ‘date’ … Read more

Replacing the title in admin list table

1. Change post title in post list column I misunderstood what you wanted – obviously. You can do that like this: add_action( ‘admin_head-edit.php’, ‘wpse152971_edit_post_change_title_in_list’ ); function wpse152971_edit_post_change_title_in_list() { add_filter( ‘the_title’, ‘wpse152971_construct_new_title’, 100, 2 ); } function wpse152971_construct_new_title( $title, $id ) { //print_r( $title ); //print_r( $id ); return ‘new’; } Making use of the admin_head-$hook_suffix … Read more

Custom columns for taxonomy list table

The manage_{TAXONOMY}_custom_column filter hook passes 3 arguments: $content $column_name $term_id So try this: function add_book_place_column_content($content,$column_name,$term_id){ $term= get_term($term_id, ‘book_place’); switch ($column_name) { case ‘foo’: //do your stuff here with $term or $term_id $content=”test”; break; default: break; } return $content; } add_filter(‘manage_book_place_custom_column’, ‘add_book_place_column_content’,10,3);

How do I set the default admin sort order for a custom post type to a custom column?

Solution from a cross post over at StackExchange from @birgire: The problem is that you run the clientarea_default_order callback too late. To fix that you only have to change the priority from the default one that’s 10: add_action( ‘pre_get_posts’,’clientarea_default_order’); to the priority of 9: add_action( ‘pre_get_posts’,’clientarea_default_order’, 9 ); But you don’t actually need two pre_get_posts … Read more

Style custom columns in admin panels (especially to adjust column cell widths)

I found a solution that works for me! I dropped this code in functions.php : add_action(‘admin_head’, ‘my_column_width’); function my_column_width() { echo ‘<style type=”text/css”>’; echo ‘.column-mycolumn { text-align: center; width:60px !important; overflow:hidden }’; echo ‘</style>’; }

Adding custom columns to custom post types

The hooks to create custom columns and their associated data for a custom post type are manage_{$post_type}_posts_columns and manage_{$post_type}_posts_custom_column respectively, where {$post_type} is the name of the custom post type. This example from the documentation removes the author column and adds a taxonomy and meta data column: // Add the custom columns to the book … Read more