function slb_subscriber_column_data( $column, $post_id ) {
// setup our return text
$output = '';
switch( $column ) {
case 'title':
// get the custom name data
$fname = get_field('slb_first_name', $post_id );
$lname = get_field('slb_last_name', $post_id );
$output .= $fname .' '. $lname;
break;
case 'email':
// get the custom email data
$email = get_field('slb_email', $post_id );
$output .= $email;
break;
}
// echo the output
echo $output;
}
function slb_register_custom_admin_titles() {
add_filter(
'the_title',
'slb_custom_admin_titles',
99,
2
);
}
function slb_custom_admin_titles( $title, $post_id ) {
global $post;
$output = $title;
if( isset($post->post_type) ):
switch( $post->post_type ) {
case 'slb_subscriber':
$fname = get_field('slb_first_name', $post_id );
$lname = get_field('slb_last_name', $post_id );
$output = $fname .' '. $lname;
break;
}
endif;
return $output;
}
The above is the code from a plugin. I was going through a course on udemy.com.
The author is not responsive.
Issue:
Although the whole approach was to create a setting without any third party, the author seems to have made the code dependent on the ACF plugin somehow. as soon as I disable the ACF plugin the screen goes blank:
I feel that the culprit is this part: get_field How can I get rid of this. what in general may be used from WordPress functions to extract this information without this?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You can use the default WP function get_post_meta to get meta from the post, here is the link to the official documentation https://developer.wordpress.org/reference/functions/get_post_meta/
For example get_field('slb_first_name', $post_id ) must be replaced with get_post_meta($post_id, 'slb_first_name', true)
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

