Hello, I am trying to retrieve attributes using shortcode to display listings on a page.
I am able to retrieve listing’s title, image, price (Number), and address (Text) and they all work fine. But when I try to retrieve value from an attribute which is type Select (the drop down list), I don’t see anything. Can you please help with this, thanks.
Hi,
Could you please clarify what you mean by “retrieve attributes using shortcode”? We don’t have a shortcode that displays the attribute value. Do you have any custom implementation, snippets, or something similar?
Hello, yes I am using code snippets plugin with a custom code snippet which is retrieving listings from a subsite into my main site (multisite setup). I am able to retrieve all other attribute’s values except the Select attribute.
For example:
Text - $rent_address = get_post_meta($rent_id, ‘hp_address’, true);
works
Number - $rent_raw_price = get_post_meta($rent_id, ‘hp_rent_price’, true);
works
Select (drop down) - $rent_community = get_post_meta($rent_id, ‘hp_community’, true);
doesn’t working
Thanks for the details.
Regular fields are stored as post meta fields with the hp_ prefix, but selectable fields (like dropdowns, checkboxes, etc.) are stored as taxonomy terms under the taxonomy name hp_listing_attributename.
For example, if you have a “language” attribute field, you can retrieve its values using core WordPress functions like wp_get_post_terms() for the taxonomy hp_listing_language. You can find more details here: wp_get_post_terms() – Function | Developer.WordPress.org
Hope this helps.
That worked like a charm, thank you!
Glad to help!
If you have a minute, please rate HivePress on the WordPress repository or Trustpilot. Your feedback means a lot to us and makes a real difference in helping us grow.
Will do, thank you!
Update: Review posted on TrustPilot.
Thank you for taking the time to leave a review! Your support makes a big difference for us ![]()
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.