Skip Navigation

[Resolved] Extend the admin search through post reference custom field

This thread is resolved. Here is a description of the problem and solution.

Problem:
Extend the admin search through post reference custom field

Solution:
There is no such native feature exists using which you can add the post reference field in admin search.

You can find proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/extend-the-admin-search-through-post-reference-custom-field/#post-919793

Relevant Documentation:

This support ticket is created 6 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by Zoren_LeoL6293 6 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#919520

Hello good day,

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?

Best regards

#919793

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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/

Following links may help you:
https://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column
https://codex.wordpress.org/Plugin_API/Filter_Reference/manage_edit-post_type_columns
hidden link
http://code.tutsplus.com/articles/add-a-custom-column-in-posts-and-custom-post-types-admin-screen--wp-24934
hidden link

#919797

Okay no worries got it. Thanks anyway!