Created
August 29, 2022 14:56
-
-
Save patrickposner/824e17f9342107042b279d8e48daeaa5 to your computer and use it in GitHub Desktop.
Filr add custom columns with example.
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
<?php | |
// First we add the titles for the columns. | |
add_filter( 'filr_header_columns', function( $columns ) { | |
// You can add as many columns as you like here. | |
$columns['purchase-order-number'] = array( | |
'title' => esc_html__( 'Purchase Order Number', 'textdomain' ), | |
'hide' => 'off', | |
); | |
$columns['another-column'] = array( | |
'title' => esc_html__( 'Just another column.', 'textdomain' ), | |
'hide' => 'off', | |
); | |
return $columns; | |
}); | |
// Now we assign content to our new columns. | |
add_action( 'filr_custom_column', function( $td, $file_id ) { | |
?> | |
<?php if ( 'purchase-order-number' === $td ) : ?> | |
<td class="purchase-order-number"> | |
<?php echo get_post_meta($file_id, 'purchase_order_number', true ); ?> | |
</td> | |
<?php endif; ?> | |
<?php if ( 'another-column' === $td ) : ?> | |
<td class="another-column"> | |
<?php echo get_post_meta($file_id, 'another_column', true ); ?> | |
</td> | |
<?php endif; ?> | |
<?php | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment