I am created a custom function to get the listings post using WP_Query. And i want to get the listing images. what is the meta_key for it?
Because if i am using “listing_images” meta_key, listing images have not shown.
I am created a custom function to get the listings post using WP_Query. And i want to get the listing images. what is the meta_key for it?
Because if i am using “listing_images” meta_key, listing images have not shown.
The easiest way is creating a listing model object:
$listing=\HivePress\Models\Listing::query()->get_by_id($post_id_here);
And then:
$urls=$listing->get_images__url();
If you want to do this on the WordPress level, it’s possible if you query all image attachments of the listing, but also filter them by the meta_key
hp_field
which equals to images
.
Hope this helps
Thanks for the response.
I am using above code but this is not working in wp_query getting latest 3 listing post.
The suggested code line is not a query for multiple listings, it can be used if you already have a listing ID or post and you can convert it into a listing object instead (to get the image URLs or any other listing field directly).
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.