Is there a way to show a Logo on the "Listings" Page but not on the actual Listing?

Hi All,

I’m building a business directory and want all of my listings to show a logo on the “listings” page where it lists all of the businesses but not on the individual listings page. Hard to describe but I’ve added some pics below to see if itll help?

Currently, the only way i can find to add a small logo image to the All Listings page is by adding it as image 1 on the individual listings page so cant see a work around currently.

I want it shown in this place on Image 1 below, but not shown on image 2.

Thanks!

:brain: Why Use a Child Theme in WordPress (and HivePress)?

A child theme lets you customize your site’s design and functionality without modifying the original (parent) theme. This is important because updates to the parent theme can overwrite your changes. A child theme keeps your custom code safe and upgrade-friendly.


:gear: How to Create a Child Theme for HivePress (e.g., RentalHive):

  1. Create a folder for your child theme
    Example name: rentalhive-child
  2. Inside that folder, create two files:
  • style.css
  • functions.php
  1. In style.css, add the following:
/*
Theme Name: RentalHive Child
Template: rentalhive
*/

In functions.php, enqueue the parent and child styles:

<?php
add_action('wp_enqueue_scripts', function () {
    wp_enqueue_style('rentalhive-style', get_template_directory_uri() . '/style.css');
    wp_enqueue_style('rentalhive-child-style', get_stylesheet_uri(), ['rentalhive-style']);
});

  • Zip the rentalhive-child folder and upload it via WordPress → Appearance → Themes → Add New → Upload.
  • Activate the child theme.

NOTE THAT YOUR THEME IS NOT CALLED RENTALHIVE, SO USE YOURS INSTEAD (E.G. LISTINGHIVE)

Step 2

:hammer_and_wrench: How to Create a Custom Attribute for a Logo Image (Slug: logo, Type: URL)

If you want to allow users to add a separate logo image to their listing, you can create a custom attribute in HivePress like this:

  1. Go to WP Admin → HivePress → Attributes.
  2. Click “Add New”.
  3. Set the following:
  • Name: Logo (or anything you prefer)
  • Slug: logo (this is important — you’ll use it in code)
  • Field Type: URL
  1. Under Display Options, uncheck all checkboxes if you don’t want it to appear automatically on the listing page or submission form.
  2. Save the attribute.

Now, when editing a listing in the backend (or if you manually add the field to the submission form), you can paste the URL of the logo image.

Step 3

Replace the Listing Image with the logo Attribute

Now that you’ve created the logo attribute, you can replace the default listing image with your custom logo in the listing card.

:file_folder: 1. Copy the Template File

  1. Go to this path in your HivePress plugin:
    wp-content/plugins/hivepress/templates/listing/view/block/

  2. Find listing-image.php

  3. Copy it into your child theme using the same folder structure:
    wp-content/themes/rentalhive-child/hivepress/listing/view/block/listing-image.php

Modify the Copied File

Open the listing-image.php in your child theme and replace everything inside with the following:

<?php
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

$logo_url = $listing->get_attribute('logo'); // Custom logo URL attribute.
$image_count = count( (array) $listing->get_images__id() );
?>

<div class="hp-listing__image" data-component="carousel-slider" data-preview="false" data-url="<?php echo esc_url( hivepress()->router->get_url( 'listing_view_page', [ 'listing_id' => $listing->get_id() ] ) ); ?>">

    <?php if ( $logo_url ) : ?>
        <a href="<?php echo esc_url( hivepress()->router->get_url( 'listing_view_page', [ 'listing_id' => $listing->get_id() ] ) ); ?>">
            <img src="<?php echo esc_url( $logo_url ); ?>" alt="<?php echo esc_attr( $listing->get_title() ); ?>" loading="lazy">
        </a>

    <?php else : ?>
        <?php if ( get_option( 'hp_listing_enable_image_preview' ) && $image_count > 1 ) : ?>
            <?php foreach ( $listing->get_images() as $image ) : ?>
                <?php if ( strpos( $image->get_mime_type(), 'video' ) === 0 ) : ?>
                    <video controls>
                        <source src="<?php echo esc_url( $image->get_url() ); ?>#t=0.001" type="<?php echo esc_attr( $image->get_mime_type() ); ?>">
                    </video>
                <?php else : ?>
                    <img src="<?php echo esc_url( $image->get_url( 'hp_landscape_small' ) ); ?>" alt="<?php echo esc_attr( $listing->get_title() ); ?>" loading="lazy">
                <?php endif; ?>
            <?php endforeach; ?>
        <?php else : ?>
            <a href="<?php echo esc_url( hivepress()->router->get_url( 'listing_view_page', [ 'listing_id' => $listing->get_id() ] ) ); ?>">
                <?php if ( $image_count >= 1 ) : ?>
                    <img src="<?php echo esc_url( $listing->get_image__url( 'hp_landscape_small' ) ); ?>" alt="<?php echo esc_attr( $listing->get_title() ); ?>" loading="lazy">
                <?php else : ?>
                    <img src="<?php echo esc_url( hivepress()->get_url() . '/assets/images/placeholders/image-landscape.svg' ); ?>" alt="<?php echo esc_attr( $listing->get_title() ); ?>" loading="lazy">
                <?php endif; ?>
            </a>
        <?php endif; ?>
    <?php endif; ?>
</div>

:white_check_mark: Result

  • If a logo URL is set, it will be shown instead of the default image carousel.
  • If no logo is provided, it will show regular pictures.
  • The whole block remains clickable and links to the listing page.

p.s. if the method above didn’t work, try this

<?php
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

$logo_url = get_post_meta( $listing->get_id(), 'hp_logo', true ); // Get logo directly from meta.
$image_count = count( (array) $listing->get_images__id() );
?>

<div class="hp-listing__image" data-component="carousel-slider" data-preview="false" data-url="<?php echo esc_url( hivepress()->router->get_url( 'listing_view_page', [ 'listing_id' => $listing->get_id() ] ) ); ?>">

    <?php if ( $logo_url ) : ?>
        <a href="<?php echo esc_url( hivepress()->router->get_url( 'listing_view_page', [ 'listing_id' => $listing->get_id() ] ) ); ?>">
            <img src="<?php echo esc_url( $logo_url ); ?>" alt="<?php echo esc_attr( $listing->get_title() ); ?>" loading="lazy">
        </a>

    <?php else : ?>
        <?php if ( get_option( 'hp_listing_enable_image_preview' ) && $image_count > 1 ) : ?>
            <?php foreach ( $listing->get_images() as $image ) : ?>
                <?php if ( strpos( $image->get_mime_type(), 'video' ) === 0 ) : ?>
                    <video controls>
                        <source src="<?php echo esc_url( $image->get_url() ); ?>#t=0.001" type="<?php echo esc_attr( $image->get_mime_type() ); ?>">
                    </video>
                <?php else : ?>
                    <img src="<?php echo esc_url( $image->get_url( 'hp_landscape_small' ) ); ?>" alt="<?php echo esc_attr( $listing->get_title() ); ?>" loading="lazy">
                <?php endif; ?>
            <?php endforeach; ?>
        <?php else : ?>
            <a href="<?php echo esc_url( hivepress()->router->get_url( 'listing_view_page', [ 'listing_id' => $listing->get_id() ] ) ); ?>">
                <?php if ( $image_count >= 1 ) : ?>
                    <img src="<?php echo esc_url( $listing->get_image__url( 'hp_landscape_small' ) ); ?>" alt="<?php echo esc_attr( $listing->get_title() ); ?>" loading="lazy">
                <?php else : ?>
                    <img src="<?php echo esc_url( hivepress()->get_url() . '/assets/images/placeholders/image-landscape.svg' ); ?>" alt="<?php echo esc_attr( $listing->get_title() ); ?>" loading="lazy">
                <?php endif; ?>
            </a>
        <?php endif; ?>
    <?php endif; ?>
</div>

p.s. not always you have to proceed as planned, you can work around another way to the solution, such as reduce the image size on the listing page so that it looks neat via css with the WP Customizer

Option 2 - just reduce the image size on the listing page via CSS

.hp-listings .hp-listing__image img {
  max-height: 300px;
  width: auto;
  height: auto;
  object-fit: contain;
}
4 Likes

Hey @andrewv,

I’m not trying to do this myself, but just wanted to say thanks on behalf of the community! :raising_hands:

This is exactly the type of community spirit that I’ve been trying to encourage others on these forums to have.

I hope that over time the forum will have a wide range of custom snippets and tweaks just like this, and, if we, as a community, can take some pressure off of the developers, then hopefully, they’ll be able to spend more time focusing on updates, bug fixes, and implementing new ideas, etc.

It’s a win-win for everyone! :trophy:

Cheers,
Chris :victory_hand:

3 Likes

This does actually work, its my bad, I hadn’t cleared my cache! Thanks for your help, this is exactly what I wanted :slight_smile: