WordPress: Adding custom columns to wp-admin posts overview

Adding custom columns to the posts overview from wp-admin is maybe simpler as you think.  You need just two hooks, one is an action named “manage_posts_custom_column” and the other one is a filter named “manage_posts_columns”.

Add custom column

With the filter “manage_posts_columns” you can add your custom column to the overview table of the posts. In my case I made the filter a little bit more complex, because I want control of the column order. The default order from wordpress is

  1. cb
  2. title
  3. author
  4. categories
  5. tags
  6. comments
  7. date
and normaly wordpress adds your custom column after “date”. In my filter function I walk with a while-loop through the default columns and add my column right after the “author” column:

If you have a more sexy solution for this, tell me :)

Adding content to your costum column

Next and final step is adding the content to your custom colum/row with the action-hook “manage_posts_custom_column”. The action takes the column-name and the post_id of the current row:

Custom columns only for a custom post type

If you want your custom column only in a custom posty, e.g. to display a custom taxonomy, then simply add the name of your custom post type to the name of the hook.

For example:

Action hook “manage_yourcustomposttypename_posts_custom_column”

Filter hook “manage_yourcustomposttypename_posts_columns”

Full example plugin code

 

Android ObjectInputStream and ObjectOutputstream snippet

At first, make your object serializable and let the IDE (in my case Eclipse) generate a serialVersionUID for you:

Writing to files with serialization and writing objects to file:

Reading files with serialization and get it as object:

Thats it!

 

How to include ActionBarSherlock in your Android-Project

If you have problems to include ActionBarSherlock in your Android project (because of not generated R.java or something) then follow this quick guide:

Include ActionBarSherlock as library in your Eclipse-Workspace.

Both project needs to compile with Android 4.0 or newer. And you must  specify a targetSdkVersion of 11 or higher in your application’s manifest .

Example:

If you want to develop for Android 2.1 then add this to your application’s manifest and also build your app with api-level 15 (Android 4.0.3)

Finally select “Project” -> “Clean” -> “Clean all projects” in Eclipse.