Hot answers tagged

24

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


13

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


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


9

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


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 ( !class_exists('...


9

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


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


6

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


6

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


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


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

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

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

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

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

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

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

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


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( 'pre_get_posts','...


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

The code from ThinkVitamin is right. I think the problem came from else where in your code. Actually, the hook manage_edit-${post_type}_columns takes an argument $columns which is an array of all registered columns. To add a new column, just add a new element to this array, like this: add_filter('manage_edit-film_columns', 'my_columns'); function ...


2

Take a look at how the rewrite $arg for your custom post type is. To get a better view of the output data, just do something like echo '<pre>'; print_r($custom_post_type_obj); echo '</pre>'; on the post type object when querying it.


2

I'd have thought it's just a matter of formulating your HTML in a way that accomodates the image alignment requirement.. You could have two seperate elements, one for the post's image, one for paragraph(s) of content, and float them side by side. Add a wrapper around the two.. So you basically have two elements, side by side and a wrapper, eg.. +----------...


2

Nth is already a class, it's a pseudo class. Why don't you just change whatever css applied to .last and apply it to #nav li:nth-child(3). If you need to target every third menu item it would be #nav li:nth-child(3n+3) Edit: Oh yah I forgot to mention support for those pesky stone age browsers. Luckily there are some good javascript libraries and jQuery ...


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.


2

I'm afraid that there is no easy way to get that done yet because the only hook i found is manage_comments_custom_column and that is an action hook and not a filter hook so you can't add columns like manage_posts_columns. so as far as i can tell the long way here is the only way. but you can almost duplicate the default edit-comments.php and extending small ...



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