Obtain the name of the attribute option

Hi, with this piece of code I was able to obtain the tag_ID of the attribute option, but I need to obtain the name of the attribute option, how do I do that?

$cidade = '';
			foreach ( $listing->_get_fields( 'view_page_primary') as $field ) {
				if ( $field->get_slug() === 'cidade' ) {
					$cidade = $field->get_value();
					break;
				}
			}
1 Like

Please try to use this code snippet to get the name of the attribute

$field->get_arg('label')

I have tried it this way, but it only returns the name of the category, and I need the name of the option that was selected in the category.
If I configure the category as “text” or “number” with the code I sent, I can obtain the values that the user entered. But when I configure the category as “selection”, I only get a number that is the tag_ID, but I need the name of that option.

Please try this code snippet

$field->get_display_value();

Thank you yevhen, it worked the way I need it.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.