0
votes

Guys I'm writting a wordpress site to run a knowldge base for our Service desk. As one person will be updating it i needed to have a field for who wrote the kb artical. I'm tring to add a custom field into my wordpress theme to display writtenby using Advance custom Fields. Now I'm using echo Knowledge Base plugin for knowldge base.

I've got as far add ing code below will display the text below the last up date value that plugin creates. However i cannot get it to put value from the custom field on the page after this. The plugin creates the page using php below the ive added the two lines as below.

$wb = get_post_meta($post->ID, 'Writtenby', true); echo '

Last Update Writtenby:'.$wb.'

';

// LAST UPDATED ON public static function last_updated_on( $args ) { echo '' . esc_html( $args['config']['last_udpated_on_text'] ) . ' ' . EPKB_Utilities::get_formatted_datetime_string( $args['article']->post_modified, 'F d, Y' ).''; $wb = get_post_meta($post->ID, 'Writtenby', true); echo '

Last Update Written by:'.$wb.'

'; }
3

3 Answers

0
votes

Advanced Custom Fields plugin use a little bit different system to store postmeta. Try to use get_field() instead get_post_meta()

0
votes

If you have the ID

$customField = get_post_meta($my_id, "_mcf_customField", true);

However if you want to get the ID from the object:

$customField = get_post_meta($post_id->ID, "_mcf_customField", true);

0
votes

After much more work looks like at the point the page was being created it had no reference to partical page not even a current one. They where writting to an array all artical numbers and info.

So by telling get_field which artical to get the writtenby field from it now displayed data and not blank

$wb= get_field('Writtenby', $args['article']->ID);