Created
September 4, 2015 20:00
-
-
Save Faisalawanisee/a2890fcd9a421acf5b41 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| manage_{$post_type}_posts_columns | |
| https://codex.wordpress.org/Plugin_API/Filter_Reference/manage_$post_type_posts_columns | |
| manage_{$post_type}_posts_custom_column | |
| https://codex.wordpress.org/Plugin_API/Action_Reference/manage_$post_type_posts_custom_column | |
| add_filter( 'manage_book_posts_columns', 'set_custom_edit_book_columns' ); | |
| add_action( 'manage_book_posts_custom_column' , 'custom_book_column', 10, 2 ); | |
| function set_custom_edit_book_columns($columns) { | |
| unset( $columns['author'] ); | |
| $columns['Price'] = __( 'Price', 'your_text_domain' ); | |
| $columns['rating'] = __( 'Rating', 'your_text_domain' ); | |
| return $columns; | |
| } | |
| function custom_book_column( $column, $post_id ) { | |
| switch ( $column ) { | |
| case 'Price' : | |
| $price = get_field('price', $post_id); | |
| if ( $price ) | |
| echo $price; | |
| else | |
| _e( 'Price Not Set', 'your_text_domain' ); | |
| break; | |
| case 'rating' : | |
| $rating = get_field('rating', $post_id); | |
| if ( $rating ) | |
| echo $rating; | |
| else | |
| _e( 'rating Not Set', 'your_text_domain' ); | |
| break; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment