Created
December 21, 2018 09:43
-
-
Save MjHead/ccf94293dc89e50e6ced143f4ece315a to your computer and use it in GitHub Desktop.
Custom callback function example
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 | |
/** | |
* Custom callback example | |
* | |
* @param string $column Column name | |
* @param int $post_id Post ID | |
* @return string | |
*/ | |
function jet_admin_column_callback_example( $column, $post_id ) { | |
return 'Example output: ' . get_the_title( $post_id ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If trying to use this to format a date for a timestamp custom field to be included in a custom post type admin panel view, How do I retrieve the contents of the custom field? event_date is the Name / ID of the custom metafield in the custom post type. The idea is that $rawdate will collect and hold the int value of the event_date meta field, and $cleardate will run the date() function and hold a string - plain english date - based on the value held in $rawdate.
I'm trying this
`
function returncleardate( $column, $post_id ) {
$rawdate = $event_date;
$cleardate = date('l jS \of F Y',$rawdate);
return $cleardate;}
`
And get nothing returned.
I know that I'm getting NULL for $rawdate due to this temporary code
function returncleardate( $column, $post_id ) { $rawdate = $event_date; return var_dump($rawdate);}
When $rawdate = get_the_title( $event_date );
Then I get the title.
When $rawdate = get_the_date( $event_date );
I get the creation date of the post.
get_the_title and get_the_date are obviously functions that are already defined somewhere.
what is the function for get the field or get the term?
I think I'm on the right track. Just need a little guidance.