Support

Account

Home Forums General Issues Is it possible to change select option text on selector based on Post Object?

Solved

Is it possible to change select option text on selector based on Post Object?

  • I have set up a Post Object field. Which by default displays as a drop-down selector. It references the Products in Woocommerce.

    By default the Post Object field pulls in the post title as the option value and as the text shown in the selector. E.g. <option value="product-title">product-title</option>

    In my case many of the items have the same title. So it is impossible to tell them apart.

    Is there a function I can set up in functions.php to modify what’s used for the option text?

    In this instance at the very least I’d like to include the product ID, and ideally the SKU.
    e.g.
    <option value="product-title">product-title - PostID - SKU</option>

    Is this possible?

  • A post object field should set the option value to the post ID and the label to the post Title.

    There is a filter that can be used to alter the label acf/fields/post_object/result.

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

You must be logged in to reply to this topic.