Display a map with all listings on the homepage

Hi HivePress team :waving_hand:

I’m using RentalHive with the Geolocation extension, and I’d like to display just the interactive map with all published listings on the homepage — without rendering the listing grid, filters, or view toggles.


:bullseye: Desired result:

On the homepage:

  • A full-width map with markers for all active listings
  • No listing cards
  • No filters
  • No pagination
  • Ideally, no additional container markup from the [hivepress_listings] shortcode

:magnifying_glass_tilted_left: What I’ve tried:

  • Using the [hivepress_listings view="map" show_map="1" per_page="0"] shortcode → still outputs listing cards
  • Hiding elements with CSS (e.g. .hp-listing--view-block) → works, but not clean and may break other pages
  • Tried [hivepress_map] — doesn’t exist
  • Looked for a specific map shortcode or a callable template partial — no luck in the docs

:folded_hands: My request:

Could you please advise:

  1. Is there a dedicated HivePress function or template part (e.g. hivepress()->template->get_part(...)) to render only the map block with markers?
  2. If not, is there a clean way to:
  • Call the map markup with listings injected as markers (filtered by status = published)
  • Inject this into front-page.php without bringing in listing cards?
  1. If this is not currently supported — what would be the best practice to implement this as a custom block?

I’m fine with using PHP, child theme templates, or even custom shortcodes — I just want to avoid hacky CSS tricks or stripping markup via JS.

Thank you in advance — your plugin is brilliant, and this would be a game-changer for many use cases (like showcasing vendors or rentals by location only).

Hi,

Please try this code snippet, it adds the [listing_map] shortcode that you can use in any page content to display all the listing markers:

add_shortcode(
	'listing_map',
	function () {
		query_posts(
			[
				'post_type'      => 'hp_listing',
				'status'         => 'publish',
				'posts_per_page' => -1,
			]
		);

		$output = ( new \HivePress\Blocks\Listing_Map() )->render();

		wp_reset_query();

		return $output;
	}
);

Please note that it’s not fully tested and showing too many markers may cause performance issues when loading the page.

Hope this helps

2 Likes

Thanks. That works amazing. I’ve tried replacing the markers but it didn’t work. Any idea what is wrong?

add_filter(
  'hivepress/v1/models/listing/geolocation_marker',
  function ($marker, $listing) {
    $categories = wp_get_post_terms($listing->get_id(), 'hp_listing_category');

    if (!empty($categories)) {
      $category_slug = $categories[0]->slug;

      switch ($category_slug) {
        case 'food':
          $marker['icon'] = 'https://your-site.com/icons/burger.png';
          break;

        case 'education':
          $marker['icon'] = 'https://your-site.com/icons/book.png';
          break;

        case 'beauty':
          $marker['icon'] = 'https://your-site.com/icons/scissors.png';
          break;

        default:
          $marker['icon'] = 'https://your-site.com/icons/default.png';
      }
    }

    return $marker;
  },
  10,
  2
);

In addition, just wanted to share - I was trying to change the size of the map, div class and css didn’t work well, so here’s my solution which worked well

  1. register shortcode with the necessary attributes
add_shortcode(
  'listing_map',
  function ( $atts ) {

    $atts = shortcode_atts(
      [
        'height' => '450px',
        'class'  => '',
      ],
      $atts,
      'listing_map'
    );

    query_posts([
      'post_type'      => 'hp_listing',
      'post_status'    => 'publish',
      'posts_per_page' => -1,
    ]);

    $map_html = ( new \HivePress\Blocks\Listing_Map() )->render();

    wp_reset_query();

    return sprint
      '<div class="%s" style="height:%s; overflow:hidden; border-radius:16px;">%s</div>',
      esc_attr($atts['class']),
      esc_attr($atts['height']),
      $map_html
    );
  }
);

  1. using the shortcode
[listing_map height="500px" class="map-hero"]

1 Like