Getting a custom attribute value

Hi, I’m having trouble getting Listinghive custom fields Attribute value using the

function my_listing_status{
$status = get_post_meta(get_the_ID(), 'hp_availability', true);
echo '<br> Current Status is:<br>' . $status;

It is returning an Empty value.

Is there a Listinghive specific code similar to this Wordpress one that can output an attribute value?

Note: I have added the attribute but it’s not returning any value using that code.

It’s better to use the HivePress API in this case, for example:

$listing = HivePress\Models\Listing::query()->get_by_id( 123 );

Then you can access the field values without checking whether it’s a meta field, taxonomy, etc. For example:


Thank you. One more thing, I have registered a custom taxonomy '“Places” for listings, now I’m having trouble finding the hivepress listing category template code that I can use in taxonomy-places.php file.

Please try adding a custom Select attribute for this purpose, HivePress will register a taxonomy automatically. For example, if you name it “places”, the taxonomy will be named “hp_listing_places”. There’s the same template used for any listing results, it’s hivepress/v1/templates/listings_view_page, you can override it via this filter hook or create a custom template without code in HivePress/Templates.


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