• I have read all topics related to this issue. Apparently this issue was fixed, but is not true for a fresh installation just realized.
    I create products by REST API and I pass attributes with an array like this:

    $quality=array('name'=>'qualita','visible'=>'true','value'=>$qualita);
    $certificate=array('name'=>'certifiato','visible'=>'true','value'=>$certificato);
    $condition=array('name'=>'condizione','visible'=>'true','value'=>$condizione);
    $attributes=array($quality,$certificate,$condition);
    $postData = array('name' =>$titolo,'type' => 'simple','regular_price' => $prezzo,'description' => nl2br($descrizione),'short_description' => nl2br($descrizione),
    'categories' => $categorie,'images'=>$immagini,'stock_quantity'=>$quantita,'manage_stock'=>true,'attributes'=>$attributes);

    Product is properly created, If I edit this product from Dashboard I see all attributes properly but if I use rest api for check this item, attributes aren’t displayed. If from the Dashboard I save again the item without mods, the attributes are now visibles from API rest.

    I have disapled all plugin and templates with non effect

    Any suggestion for fix this issue ?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator threadi

    (@threadi)

    You mention products. WordPress itself does not recognize such content types. Are you using a shop plugin, possibly WooCommerce? What is the REST API endpoint you are referring to?

    Thread Starter servitel

    (@servitel)

    Yes I use WooCommerce
    The endpoint I use is this:
    /wp-json/wc/v3/products



    Moderator threadi

    (@threadi)

    I recommend getting in touch with WooCommerce’s support about this via https://woocommerce.com/my-account/create-a-ticket/ if you have any of their paid WooCommerce products or https://ww.wp.xz.cn/support/plugin/woocommerce/ if you do not.

    Wajid Ali

    (@wajid-ali-tabassum)

    Hi @servitel, this is not a WordPress core issue — it’s related to how WooCommerce expects attributes to be structured in the REST API request.

    I was able to reproduce the same behavior:

    • Product is created successfully
    • Attributes are visible in admin
    • But missing in /wp-json/wc/v3/products response
    • After re-saving in admin, attributes appear correctly

    This happens because the attribute payload is not fully aligned with the WooCommerce REST API schema.

    🔍 Problem

    In your code, attributes are defined like this:

    $quality = array('name'=>'qualita','visible'=>'true','value'=>$qualita);

    Issues here:

    • value is not the correct field (should be options)
    • "true" is a string, not a boolean
    • Missing variation key
    • options must always be an array

    ✅ Solution

    Update your attributes to match the expected structure:

    $quality = array(
    'name' => 'qualita',
    'visible' => true,
    'variation' => false,
    'options' => array($qualita)
    );

    $certificate = array(
    'name' => 'certifiato',
    'visible' => true,
    'variation' => false,
    'options' => array($certificato)
    );

    $condition = array(
    'name' => 'condizione',
    'visible' => true,
    'variation' => false,
    'options' => array($condizione)
    );

    $attributes = array($quality, $certificate, $condition);

    💡 Explanation

    When attributes are sent with incorrect keys (value instead of options), WooCommerce still stores them as post meta, which is why they appear in the admin UI.

    However, they are not properly registered as product attributes internally, so they are excluded from the REST API response.

    When you manually re-save the product in admin, WooCommerce normalizes the data — which is why they start appearing in the API afterward.

    ✅ Result

    After fixing the payload:

    • Attributes will be correctly stored
    • They will immediately appear in the REST API response
    • No need to re-save products from admin

    🔧 Additional note

    If you are using global attributes (e.g. pa_*), you should pass the attribute id instead of name.

    This should resolve the issue without needing any plugin/theme changes or WooCommerce support escalation.

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.