Skip to content

Instantly share code, notes, and snippets.

@propertyhive
Created August 18, 2017 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save propertyhive/39bfa6c7e58abcd4697203e4d92123f5 to your computer and use it in GitHub Desktop.
Save propertyhive/39bfa6c7e58abcd4697203e4d92123f5 to your computer and use it in GitHub Desktop.
Add custom columns to admin property list
add_filter( 'manage_edit-property_columns', 'lee_edit_columns' );
function lee_edit_columns( $existing_columns ) {
if ( empty( $existing_columns ) && ! is_array( $existing_columns ) ) {
$existing_columns = array();
}
$columns['reference_number'] = __( 'Reference', 'propertyhive' );
return array_merge( $columns, $existing_columns );
}
add_action( 'manage_property_posts_custom_column', 'lee_custom_columns', 2 );
function lee_custom_columns( $column ) {
global $post, $propertyhive, $the_property;
if ( empty( $the_property ) || $the_property->ID != $post->ID )
{
$the_property = new PH_Property( $post->ID );
}
switch ( $column ) {
case 'reference_number' :
{
echo $the_property->reference_number;
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment