I want a post meta of the published post, below is the code but I didn't get it. Appreciate if anyone can help me here:
class BarrioBlog {
function __construct() {
add_action( 'publish_post', array( $this, 'on_publish_post' ), 10, 2 );
}
function on_publish_post($post_id, $post) {
echo ' custom field: ' . get_field('channel', $post_id);
exit;
}
}
save_post
hook instead? It fires multiple times, but if you use that hook and check whether$_POST
contains any data, and only do your action when it does, you'll have access to all the postmeta.