Custom Columns for Custom Post Type Manager

add_action(‘manage_edit-pricing_columns’, ‘manage_pricing_columns’); add_action(‘manage_pricing_posts_custom_column’, ‘manage_pricing_custom_columns’); function manage_pricing_columns($_columns) { $new_columns[‘cb’] = ‘<input type=”checkbox” />’; $new_columns[‘title’] = _x(‘Pricing Item’, ‘wp’); $new_columns[‘categories’] = _x(‘Type’, ‘wp’); $new_columns[‘date’] = _x(‘Created’, ‘wp’); return $new_columns; } function manage_pricing_custom_columns($column, $post_id){ global $post; switch($_columns) { case ‘pricing_type’: $pt = get_the_terms( $post_id, ‘pricing_type’ ); echo $pt[0]->name; break; default: break; } }

Dynamically set taxonomy term and show admin notice on post save

Okay, so just in case anyone needs help on the same thing I did… here is my solution. Instead of a php/wordpress solution, I used javascript. Id love to see the php/wordpress solution if someone wants to post it. <?php // Admin Custom JS add_action(‘admin_head’, ‘admin_custom_js’); function admin_custom_js() { ?> <script> // update date (month) … Read more

How can I remove the editor from the ‘main posts page’?

WordPress already does this by default, so long as that page doesn’t have any existing content. Plus it adds a notice explaining why the editor isn’t there. These are the lines already in WordPress Core: if ( $post_ID == get_option( ‘page_for_posts’ ) && empty( $post->post_content ) ) { add_action( ‘edit_form_after_title’, ‘_wp_posts_page_notice’ ); remove_post_type_support( $post_type, ‘editor’ … Read more

Force category choice before creating new post

Use the ‘save_post’ hook to programmatically enteract with your new post when it is created, then use the wp_set_post_terms() function to assign your term, add_action(‘save_post’,’set_post_default_category’, 10,3); function set_post_default_category($post_id, $post, $update){ if($update) return; //only want to set if this is a new post! if(‘post’ !== $post->post_type) return; //only set for post_type = post! $term = get_term_by(‘slug’, … Read more