Where the code for the block listings? Trying to make the homepage show listings filtered by metadata

I have a hivepress/listinghive attribute called auction_start_date which is in wp_termmeta as ‘hp_auction_start_date’

By default, the block has order by date added, title, and random.

My hope is to modify the block code to include an order by for “current auctions” which would only show listings where the attribute auction_start_date has a date greater than or equal to today. I also want an order by for “past auctions” which would only show listings where the attribute auction_start_date is less than today. This approach should give me the ability to use the same code to have two different blocks on the home page, one showing current and upcoming auctions and one showing past auctions.

I’ve been looking at the code in plugins/hivepress/includes/blocks/class-listings.php
and plugins/hivepress/includes/models/class-modal.php

I have had almost no luck getting the query to alter its default behavior. Am I in the wrong files?

Thank you.

Unfortunately there’s no simple code snippet for this, but if you’re familiar with WordPress customizations this may be possible. If you use the Date type for these fields then they are stored in wp_postmeta, not wp_termmeta. Please try using this hook to detect the listing query (by “hp_listing” post type, and other conditions like “is_home”) and alter it pre_get_posts | Hook | WordPress Developer Resources

Hope this helps

Thanks! Think I’ve got it.

@djuggler I’m trying to do something similar as you on this post.
Would you be kind to share some of your code here or my email?

Yes. I will post but it may be tomorrow before I can do it. I think what I have will help you or get you in the right direction.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.