Last active
August 29, 2015 14:05
-
-
Save stephenharris/26d09f5cfe4d0f5651f0 to your computer and use it in GitHub Desktop.
A snippet which adds a custom column, and removes an existing column from the Events admin table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* A snippet which adds a custom column, and removes an existing column from the Events admin table | |
* | |
* Specifically, this snippet removes the existing 'Reoccurrence' column and replaces it with another column. | |
* This new column does exactly the same thing, but you can change it's behaviour as desired. | |
* | |
* @see http://wp-event-organiser.com/forums/topic/better-reoccurrence-display-in-admin-panel/ | |
*/ | |
/** | |
* Adds custom columns to Event CPT table | |
*/ | |
function my_add_event_add_column( $columns ) { | |
$columns['recurrence_detail'] = __( 'Reoccurrence', 'eventorganiser' ); | |
//Optional, remove default column | |
unset( $columns['reoccurence'] ); | |
return $columns; | |
} | |
add_filter( 'manage_edit-event_columns', 'my_add_event_add_column', 15 ); | |
/** | |
* What to display in custom columns of Event CPT table | |
*/ | |
function my_event_fill_columns( $column_name, $id ) { | |
global $post; | |
$event_id = ( empty( $post->event_id) ? $id :'' ); | |
if( 'recurrence_detail' != $column_name ){ | |
return false; | |
} | |
//Change this as required. | |
eo_display_reoccurence( $event_id ); | |
} | |
add_action( 'manage_event_posts_custom_column', 'my_event_fill_columns', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you so much Stephen! This is really a big help. If someone needs the snippet for having the reoccurences listed in my way here we go.
The function first:
Then change the function call in Stephens code from:
eo_display_reoccurence( $event_id );
To:
show_custom_reoccurence( $event_id );