I just need help, I have two custom post type then in the second custom post type I have post reference custom fields assigned that connects to first custom post type. So I want to extend the admin search in the second custom post type records where I could query the post title of the first custom post type which is connected to post reference. How could I do that stuff?
Hello. Thank you for contacting the Toolset support.
Well - there is no such native feature exists using which you can add the post reference field in admin search.
To display the post reference custom field value with column, you should try to add the following code to your current theme's functions.php file.
//Add custom column
add_filter('manage_edit-employee_columns', 'my_columns_head');
function my_columns_head($defaults) {
$defaults['Parent'] = 'Post Reference field Value';
return $defaults;
}
//Add rows data
add_action( 'manage_employee_posts_custom_column' , 'my_custom_column', 10, 2 );
function my_custom_column($column, $post_id ){
switch ( $column ) {
case 'Parent':
$id = get_post_meta($post_id,'wpcf-ref-student',true);
echo do_shortcode("[wpv-post-title id=".$id."]");
exit;
break;
}
}
Where:
- Replace employee with your second post type name
- Replace ref-student with your post reference field name
To involve the parent title in search , This may need custom programming which is beyond the scope of our support policy. If you need custom programming for your project, please feel free to contact our certified partners.
=> https://toolset.com/contractors/