Hot answers tagged

21

OK - in the end turned out to be fairly simple - as I'd had some kind of mental block - menu_order is a variable in the $post object (thanks to @brady for reminding me of that). @scribu's post on creating sortable column values then gives the rest. So, assuming the custom post type is called header_text, these are the functions and hooks that are needed: ...


12

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>'; }


11

Changing admin columns belongs to a plugin, not to a theme file, because themes should never change anything else than frontend output. You can get the complete plugin here: Plugin Product Editor Column. Looking at the docs you linked to, I see the plugin author requires a child class that mixes multiple separate tasks. That’s not good. We will see in a ...


9

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 ( ...


9

See the follow-up post: http://scribu.net/wordpress/sortable-taxonomy-columns.html


8

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 ...


7

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, ...


5

Changing the public argument of register_post_type() will remove the link to view your custom post type publicly. 'public' => false, See: WordPress Codex Note that this will also hide your custom post type from the admin navigation menus, which you might not want. To hide the 'View Post' link but keep your post type in the admin menus use show_ui as ...


5

There are far better ways of doing this. Instead of modifying the user table, make use of User Meta. It has a dedicated table, and works the same way as post meta, but for users. add_user_meta get_user_meta update_user_meta There are many tutorials explaining how to add additional fields to the user profile using User meta to store them, and it's how a ...


5

Your problem is a simple typo: array($this, 'manage_post_columns', 10, 2) VS. array($this, 'manage_post_columns'), 10, 2 I guess you see the difference


5

It's because you are checking 'event_date' == $vars['event_date'] not 'event_date' == $vars['orderby]. But don't use the request filter. Instead: add_action( 'pre_get_posts', 'event_column_orderby' ); function event_column_orderby( $query ) { if( ! is_admin() ) return; $orderby = $query->get( 'orderby'); if( 'event_date' ...


4

You should be able to set the column width using CSS quite easily. You can use the .column-{name} class to apply styles to the column cells (both th and td). For example: .column-mycolumn { width:20%; } Make sure you don't have other styles overruling your column width because of CSS specificity rules. Also, long words without spaces or large images could ...


4

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 = ...


4

The hook for these columns is manage_media_columns. So just filter the columns here: add_filter( 'manage_media_columns', 'wpse_77687_remove_media_columns' ); function wpse_77687_remove_media_columns( $columns ) { unset( $columns['author'] ); unset( $columns['comments'] ); return $columns; }


4

Thanks Nicusor: Works great. I was able to change the width of selected columns on the Posts panel (e.g Title, Author, Categories) with your solution as follows: add_action('admin_head', 'my_admin_column_width'); function my_admin_column_width() { echo '<style type="text/css"> .column-title { text-align: left; width:200px !important; ...


4

Here is an interesting approach: THE PLAN AND LOGIC: Custom fields are a build in functionality that will fit our needs perfectly. We can set a new custom field and then use that field to enter and store our custom data. We can then use a widget to display this custom content in the sidebar of our single pages Example of custom field in post editor ...


4

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 } ...


4

You are using wrong number of arguments in add_filter, you specified to get 2 arguments and you are looking for third one: Update your add_filter code to this: add_filter( 'manage_post_tag_custom_column' , 'my_custom_column' , 10 , 3 ); The 3 in the end tells the filter to provide all the three arguments to your function.


3

The problem is that by setting the posts to be ordered by _start_event_datetime you're creating the implicit assumption that the post will have that meta. This means the SQL query WordPress generates will only fetch posts of your custom post type with that meta. There are two possible solutions to this: Replace your current query with a slightly more ...


3

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( ...


3

here is a modified version of your class that should work: class Add_Blog_ID { public static function init() { $class = __CLASS__ ; if ( empty( $GLOBALS[ $class ] ) ) $GLOBALS[ $class ] = new $class; } public function __construct() { add_filter( 'wpmu_blogs_columns', array( $this, 'get_id' ) ); ...


3

EDIT- this answer is old, there are better options. a few plugins - pods, magic fields, custom fields template. or you can DIY with some meta boxes and tinymce editors, see this answer.


3

i did something similar with some radio buttons and a special taxonomy. i worked almost exclusively from the following 2 tutorials: http://shibashake.com/wordpress-theme/expand-the-wordpress-quick-edit-menu http://scribu.net/wordpress/sortable-taxonomy-columns.html though i was working with a taxonomy, the scribu tutorial actually links to another scribu ...


2

First: If you're adding stuff to hooks or filters, you should allways wrap the action calls in a separate function and hook it (in your case:) to admin_init: function wpse_hook_isv_columns() { add_action('manage_media_custom_column', 'isv_custom_media_column_content',10,2); add_filter('manage_media_columns', 'isv_custom_media_column_headings'); } ...


2

It doesn't have one and it doesn't advertise it either. Check the WordPress.org page, it advertises "three layout choices" and "three footer areas" but nowhere does it say it has a 3 column design. In fact, on default single pages it doesn't even have a 2 column design as it has no sidebar.


2

I suggest using the Advanced Custom Fields plugin for this. You can use it to add other entry fields to a post type (in this case, you'd probably want to add it to the Page type). In your case, you would probably want two other Wysiwyg Editor fields so you can write with formatting. The trick will be that, if you assign the new fields to the Page post type, ...


2

To customize which fields are shown in Pods UI, you can filter the default UI options through this filter / function combination. Overriding the $ui array with the options you wish to customize, this can be pretty quick and easy. function pods_ui_test ( $ui ) { // Test on UI Column $ui[ 'fields' ][ 'manage' ] = array( 'city' => 'City', ...


2

I had a similar situation and I based myself on </wp-admin/includes/class-wp-posts-list-table.php>:499 (function single_row {...case 'title') Copy the $actions creation block, and associated variables, (which looks something like this) to your manage_{post_type}_posts_custom_column action: $post = get_post( $post_id ); setup_postdata( $post ); $title = ...


2

It´s even easier than you belive. You have this two functions on wp: manage_posts_columns (notice the "posts" part) and manage_posts_custom_column (again "posts") You have same thing for pages, "manage_page_posts_columns" and "manage_page_posts_custom_column" (notice the "page_posts" part) So, if you need to add those cols for x post type, you only ...


2

You can use jQuery to do that. Try this in your header : $(document).ready(function() { $("#mymenu li:nth-child(3n+3)").addClass("last"); }); Note : for this to work you need to have enqueued jQuery.



Only top voted, non community-wiki answers of a minimum length are eligible