Created
August 18, 2017 09:00
-
-
Save propertyhive/39bfa6c7e58abcd4697203e4d92123f5 to your computer and use it in GitHub Desktop.
Add custom columns to admin property list
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
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