Skip Navigation

[Resolved] Need custom field to be visible during BULK EDIT action

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

This topic contains 4 replies, has 2 voices.

Last updated by AlimB3245 2 months ago.

Assisted by: Waqar.

Author
Posts
#2683600

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

#2683725

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

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

#2683774

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

#2684073

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

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

#2684356

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

AlimB3245 confirmed that the issue was resolved on 2024-02-21 08:13:35.
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.