Home Forums General Issues Replace category name by a ACF value


Replace category name by a ACF value

  • Hi everyone,

    I spent the last few hours to find an answer by myself but I wasn’t able to. So I hope you’ll be able to help me. Thank you in advance !

    I’m using WooCommerce. My products are synced with a 3-rd party through a CSV imported regularly with WP All Import.

    My problem is that the products categories in the CSV are the ID of the categories and not the name of it. I’ve another file with the ID in one column and the name in another column.

    As a workaround, I created a custom field for the product_cat taxonomy where I’ll import the readable name of the category and the default name field will be filled with the ID so I can match the product with the category when I import them.

    At this stage, the categories shown on the website are numbers as the default field is filled with the ID. And the name of the category is imported in the custom field that I created.

    What I want to achieve is to replace on the front-end the product category name from the default field by the value contained in my custom field.

    Is this possible ?

    Thank you.

  • Hello,

    I find the answer. You don’t need ACF for that.

    You can import these values by:

    1) Importing the values as shown here:

    2) Adding the following code snippet to the function editor.

    function my_custom_field($value, $post_id, $key, $existing_meta_keys, $import_id) {
        if ($key == "wc_productdata_options") {
            $value = array($value);
        return $value;
    add_filter('pmxi_custom_field', 'my_custom_field', 10, 5);

    That should do it.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Replace category name by a ACF value’ is closed to new replies.