How to stop some specific published listings from being listed?

Hi @hamid,

If I understand your request correctly, I think Ihor’s reply further down the page on the topic you linked to may be of use to you:

add_filter(
	'hivepress/v1/templates/listing_view_block/blocks',
	function ( $blocks, $template ) {
		$listing = $template->get_context( 'listing' );

		if ( $listing ) {
			$blocks = hivepress()->template->merge_blocks(
				$blocks,
				[
					'listing_container' => [
						'attributes' => [
							'id' => 'listing-' . $listing->get_id(),
						],
					],
				]
			);
		}

		return $blocks;
	},
	1000,
	2
);

Once you add the PHP snippet above to your site, each Listing block will have a unique ID which you can then use to target the specific Listings you want. You can then use a CSS snippet like the following example to hide them from search results:

#listing-123,
#listing-456,
#listing-789 {
	display: none !important;
}

Notes:

  • Update 123,456, and 789 with your actual listing IDs.
  • You’ll need to inspect each Listing block’s source code to identify the unique ID.

The result will be the specified Listing blocks will be hidden from search results, while still being fully accessible by linking to them, or visiting their URL directly.

I hope this helps!

Cheers,
Chris :victory_hand:

1 Like