Update Post Title from Relation Field (Pods.io Framework)
Tue Sep 19 2023 12:54:24 GMT+0000 (Coordinated Universal Time)
Saved by
@SumairAhmed
/**
* This filter fills in the post name for our custom post type
*/
add_filter( 'wp_insert_post_data' , 'gnt_modify_post_title' , '99', 2 );
function gnt_modify_post_title($data) {
//only run for our post type
if ($data['post_type'] == 'hbl_product') {
//get title from field
$pod = pods( 'hbl_product', get_the_id() );
//get the value for the relationship field
$fund_name = $pod->field( 'selected_fund.fund_name', get_the_id() );
//create a post title
$data['post_title'] = "$fund_name";
}
return $data;
}
content_copyCOPY
https://hblamc.troutinc.net/wp-admin/admin.php?page
Comments