Tell us what you are trying to do?
I have a custom post called 'Opticians' and one of the custom fields is STORES and I need to update this field for all the opticians and instead of doing this one at a time, I'd like to do it in bulk.. but I don't know how to make this field appear when I list all the opticians and select and try to EDIT in bulk
Is there any documentation that you are following?
No
Is there a similar example that we can see?
What is the link to your site?
hidden link
Hi,
This feature is not available in Toolset plugins, so it will require some code customization.
Here are tutorials on adding customization to the WordPress bulk edit feature to also include custom field(s):
hidden link
hidden link
For more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/
regards,
Waqar
Hi Waqar
Thanks for the prompt update and response.
The wordpress bulk edit links provided by you were helpful but I think I am not technical enough to try that out. However I'd like to experiment with trying to update the database. Could you help me with an SQL query on how to select the custom post from the wordpress database. I am not clear about how toolset creates the relations and some quick tip on how to structure the query would be of great help. Which tables do I need to join to get the fields connected to a custom post of type 'opticians'?
Regards,
Alim
Hi Alim,
I'm not very proficient with direct SQL queries myself, but found the following snippet that you can use to programmatically update a specific custom field's value, across a particular post type:
$target_post_type = 'portfolio';
$target_field_slug = 'sticky';
$value_to_set = 'new-value';
$args = array(
'post_type' => $target_post_type,
'posts_per_page' => -1,
'post_status' => 'publish'
);
$posts_array = get_posts( $args );
// loop through those posts 1 by 1
foreach ($posts_array as $post) {
// get current value of the field
$current_value = get_post_meta( $post->ID, 'wpcf-'.$target_field_slug, true );
// if current value is not equal to default value, set default value
if( $value_to_set != $current_value ) {
update_post_meta( $post->ID, 'wpcf-'.$target_field_slug, $value_to_set );
}
}
This snippet sets 'new-value' for the custom field with slug 'sticky' for all published 'portfolio' posts.
regards,
Waqar
Thanks for the snippet Waqar.
I am not sure I will be able to use it myself with my limited expertise but at least I have some direction to pursue in case I feel like trying it out.
Thanks for your time and effort. Really appreciate it.
Regards,
Alim