Correct method to retrieve attribute in schema

Hi HivePress Support,

I’m working on adding structured data (Schema.org) to my listings and need help retrieving the Pets Allowed field correctly.

Currently, I’m using $listing->get_pets(), but it returns an empty value. I’ve also tried:

  • $listing->get_field('pets')
  • get_post_meta($listing->get_id(), 'pets', true)

None of these methods retrieve the selected option from the Pets Allowed attribute in HivePress.

Here’s how my Pets Allowed field is set up:

  • Field Type: Single Select
  • Options: Allowed, Cats Only, Dogs Only, Not Allowed

Can you confirm the correct method to retrieve this attribute in HivePress?

Kind regards,

Jovica

Hi,

Please make sure that the $listing object is available, and if the attribute field name is “perts”, then this code should return the selected option label:

$listing->display_pets()

Hope this helps

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