Conditionally show listing page menu item

Howdy! I’ve added a custom menu item on the listing page, “Gallery”.

I’ve then added a custom ID to the listing-images.php via a child theme:


All working great, apart from when there’s no images on a listing. As the ID doesn’t exist, the anchor link doesn’t work.

Now, I’ve also got Reviews enabled and when there’s a review, the “Reviews” menu item appears and where there aren’t any, it doesn’t.



I know this will be a customisation but I’m just looking for where I can find the logic that makes the Reviews toggle work so I can (hopefully) take that and make it work for my custom Gallery link.

Just looking for a point in the right direction :slight_smile:


Please try to wrap the adding of the menu item in the snippet you are using with this condition:

if(is_singular(‘hp_listing’) && has_post_thumbnail()) {…}

​I hope this is helpful to you.

1 Like

Amazing! Thanks so much – worked like a charm :+1:

1 Like