Unique number or ID

I need to generate a unique id number for each listing. I need this to be displayed with the listing so that visitors can refer to it when making request about the listing. Something like the ‘property number’ on the VRBO vacation rentals site. It would be nice if there was an option to create an attribute with the field type "unique ID’

The WordPress Post ID would be ok to use, but I would need to find a way to expose this on the listing page. Can this be done?
By the way, I am using the elementor widgets. They work and look well but don’t seem to have many options.

Thanks for your feedback, we’ll consider adding a new attribute type for unique IDs. In the current version, the easiest way would be to insert the listing ID (WordPress post ID) into the listing_view_page template Customizing Templates I HivePress Developer Docs - YouTube

I’d too appreciate having an attribute for unique IDs. Thank you for consideration.

Please try this PHP snippet as a temporary solution. It will add the listing id above the listing title on the single listing page

add_filter(
	'hivepress/v1/templates/listing_view_page/blocks',
	function ($blocks, $template){
		$listing = $template->get_context('listing');
		
		if(!$listing){
			return $blocks;
		}
		
		return hivepress()->helper->merge_trees(
					[ 'blocks' => $blocks ],
					[
						'blocks' => [
							'page_content' => [
								'blocks' => [
									'listing_unique_id' => [
										'type'   => 'content',
										'content' => '<p>#'.$listing->get_id().'</p>',
										'_order' => 5,
									],
								],
							],
						],
				]
				)['blocks'];
	},
	1000,
	2
);
2 Likes

Thank you yevhen. Inserting the post ID this way will work for my project.
Steve at Zala

I would like to figure out how to place this ID number somewhere else on the listing page.

If you are familiar with code customization then it is possible to use the snippet above to change the position of the ID number on the page. Here is a tutorial on how to customize templates Customizing Templates I HivePress Developer Docs - YouTube

hey, is there a way, to get this id also into the permalink?

thanks!

If you mean adding listing IDs to their URLs please check the available options in Settings/Permalinks. These are WordPress-level settings, I also found this solution (listings are implemented as “hp_listing” post type) permalinks - Put post ID on the custom post type URL - WordPress Development Stack Exchange

2 Likes

Thanks for code, but it needs to show in blocks, primary listings and anyone can search ID via search and result redirect to listing page

Thanks for your feedback, we’ll consider adding this feature. In the current version implementing the changes you described would require further customizations.

It works and show listings ID but now how can I find for example #1555 listing id in backend or frontend.

Example: user send email to vendor and ask for more info about list id #1555

How vendor can find this id easily?

We rely on WordPress search and it searches only titles & descriptions by default (also any attributes that you mark as Indexed), but we’ll consider adding custom support for searching IDs. If you use HivePress messages, then email notifications have “New reply to %listing_title%” subject, also the listing link should appear in the message in Account/Messages (if it’s sent via the listing page).

1 Like