Location Required before displaying listings

How can I hide the listings displayed when the user clicks on a category?
What I would like is for the user to click on a category on the main page and have the website take them to the listing page, but have the contents be empty until they enter a location. The location is already set to required.
Is there a way to do this with a hook?

Please try this PHP snippet

add_filter(
	'hivepress/v1/templates/listings_view_page',
	function ($template){
		if(!isset($_GET['location'])){
			$template = hivepress()->helper->merge_trees(
			$template,
			[
				'blocks' => [
					'listings' => [
						'type' => 'content',
						'content' => '<h3>Please enter location to view listings</h3>',
					],
					
					'listing_pagination' => [
						'type' => 'content',
					],
					
					'listing_count' => [
						'type' => 'content',
					],
					
					'listing_sort_form' => [
						'type' => 'content',
					],
				],
			]
		);
		}
		
		return $template;
	},
	1000
);

Thank you, this works.
I added

'page_sidebar' => [
    'type' => 'content',
],

to the blocks in this function to also hide the filtering sidebar

1 Like

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