I’m creating a custom code for the listing and I’m trying to retrieve the listing meta. I have successfully retrieved the text fields but I’m having trouble retrieving the file upload. I’m using this code get_post_meta( get_the_ID(), ‘attributename’, true ). May I ask if there’s a different way how to retrieve the file upload
If you mean to get listing images, then please try to use HivePress functions
$listing = \HivePress\Models\Listing::query()->get_by_id(listing_id_here);
$listing_images_id = $listing->get_images__id();
Then it is possible to get attachment information by their id from model Attachment in this way
\HivePress\Models\Attachment::query()->get_by_id(attachment_id_here);
But please note that it can require further customization. If you are not familiar with the code customization then please consider hiring someone for custom work https://fvrr.co/32e7LvY
I actually need the attachment urls and not the ID because I need to display the image itself through a custom code. Is there a designated function for that? I tried looking into your documentation but I’m not sure if I missed it.
It is possible to use this code snippet to get the attachment URL
$attachment = \HivePress\Models\Attachment::query()->get_by_id(attachment_id_here);
$attachment_url = $attachment->get_url()
Also, it is possible to check other attachment methods here HivePress Code Reference
But please note that it can require further customization. If you are not familiar with the code customization then please consider hiring someone for custom work https://fvrr.co/32e7LvY
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.