I have created a template in the wp-admin to replace the default listings page. It eliminates the sidebar and has the search form at the top, the listings in 3 colums, then pagination. Right now it shows all listings. I have an attribute called “auction_start_date” another called “auction_end_date” I would like to pass in a query variable (eg. ?t=past or ?t=current) and have the listing pages show only all listings where the end_date is before today for ?t=past OR show only all listings where the end_date is equal to or greater than toady for ?t=current.
If I go into plugins/hivepress/includes/blocks/class-listings.php and put a var_dump($listing) after $listing = Models\Listing::query()->get_by_id( get_post() ) I get a large dump of data which includes the data dump below. However, var_dump($listing->auction_start_date) returns NULL. If I can just get that value of “2023-11-06 09:00:00” then I’ll be done. How do I get that date so that I can make a conditional statement on it?
Thanks.
[“auction_start_date”]=>
object(HivePress\Fields\Date)#2510 (27) {
[“args”:protected]=> array(18) {
[“display_type”]=> string(4) “date”
[“display_template”]=> string(21) “Auction date: %value%”
[“label”]=> string(18) “Auction Start Date”
[“type”]=> string(4) “date”
[“_order”]=> int(101)
[“required”]=> bool(true)
[“description”]=> NULL
[“placeholder”]=> NULL
[“min_date”]=> NULL
[“max_date”]=> NULL
[“offset”]=> NULL
[“time”]=> bool(true)
[“_display_areas”]=> array(3) {
[0]=> string(18) “view_block_primary” [1]=> string(17) “view_page_primary” [2]=> string(19) “view_page_secondary”
}
[“context”]=> array(2) {
[“listing”]=> RECURSION
[“model”]=> string(7) “listing”
}
["_indexable"]=> bool(true)
["_external"]=> bool(true)
["_alias"]=> string(21) "hp_auction_start_date"
["name"]=> string(18) "auction_start_date"
}
["display_type":protected]=> string(4) "date"
["display_template":protected]=> string(21) "Auction date: %value%"
["name":protected]=> string(18) "auction_start_date"
["label":protected]=> string(18) "Auction Start Date"
["description":protected]=> NULL
["statuses":protected]=> array(0) { }
["value":protected]=> string(19) "2023-11-06 09:00:00"
["parent_value":protected]=> NULL
["filter":protected]=> array(4) {
["name"]=> string(18) "auction_start_date"
["type"]=> string(4) "DATE"
["value"]=> string(19) "2023-11-06 09:00:00"
["operator"]=> string(1) "="
}
["disabled":protected]=> bool(false)
["required":protected]=> bool(true)
["errors":protected]=> array(0) { }
["attributes":protected]=> array(5) {
["data-format"]=> string(11) "Y-m-d H:i:s"
["data-display-format"]=> string(12) "F j, Y g:i a"
["data-time"]=> string(4) "true"
["data-component"]=> string(4) "date"
["class"]=> array(2) {
[0]=> string(8) "hp-field" [1]=> string(14) "hp-field--date"
}
}
["context":protected]=> array(2) {
["listing"]=> *RECURSION*
["model"]=> string(7) "listing"
}
["placeholder":protected]=> NULL
["format":protected]=> string(11) "Y-m-d H:i:s"
["display_format":protected]=> string(12) "F j, Y g:i a"
["min_date":protected]=> NULL
["max_date":protected]=> NULL
["enabled_dates":protected]=> array(0) { }
["disabled_dates":protected]=> array(0) { }
["disabled_days":protected]=> array(0) { }
["offset":protected]=> NULL
["window":protected]=> NULL
["multiple":protected]=> bool(false)
["time":protected]=> bool(true)
}
https://example.com/listings/?t=past would show only listings with the attribute “end_date” before today.
https://qa.furrow.com/listings/?t=current would show only listings with the attribute “end_date” equal to today or in the future.
I’ve been all through the code and scouring the dev doc Getting started - Developer Docs but I’m not having much success.
Any suggestions?
Thank you.