Hide Primary Attributes container if optional attributes are left unfilled

Hey @everyone,

I’m using the Primary Attribute section to display various attributes that I’ve marked as optional. However, I noticed that if a user doesn’t complete any of these optional fields, the parent container still renders on the frontend of the Vendor profile and Listing pages, leaving behind an unwanted empty placeholder.

I’ve been tinkering with this and came up with a CSS solution that fixes it. Sharing it here in case it’s useful for anyone else, though; I also think this would be a great addition to HivePress core! :slight_smile:

/* Hide Primary Attributes container if optional attributes are left unfilled */
.hp-vendor__attributes--primary:not(:has(> *:not(:empty))),
.hp-listing__attributes--primary:not(:has(> *:not(:empty))) {
    display: none !important;
}

Cheers,
Chris :victory_hand:

2 Likes

Hi @ChrisB,

Thanks for the solution, we also plan to improve this in future updates.

On the PHP level, there is now an optional=true parameter that was introduced later. It prevents the container from rendering when there is no content.

1 Like