Expired Custom Post Types Listings
This topic contains 22 replies, has 4 voices, and was last updated by Stiofan O’Connor 7 years, 10 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
August 26, 2017 at 9:44 am #392985
Hi,
I’ve configured a couple of custom post types with custom fields etc… I would like to use a date added by a custom field to manage the listing expiration.For example I have the “Expiring Date” field, I would like to create two listings pages one for the active listings and an “archive” page for the expired listings.
Is there a specific method to achieve this structure?
Thanks!
AndreaAugust 26, 2017 at 10:25 am #392989Use these automatic URLs:
/events/?etype=past
/events/?etype=upcomingOn the events page, you can select from past, future, today and all.
Thanks
August 26, 2017 at 10:51 am #392991Thanks for the reply.
It’s mandatory to use the event type?I need three different custom post types because I would like three different add listing forms.
For now everything works and I think that the event section will be OK with these links but I don’t know how to manage other custom post types (not necessary events).
Thanks.
AndreaAugust 26, 2017 at 11:40 am #392996You do not have to use Events, but it the only CPT that can be sorted like you want.
August 26, 2017 at 12:17 pm #393001Hi,
I’m sorry but I’m not understanding..I don’t want sorting, I would like to filter custom post types if a date in a custom field is older than today.
So if the expired date is older than today I’ll not show the listing.
Can I add the filter as a parameter in the url?
Thanks.
AndreaAugust 26, 2017 at 12:30 pm #393002If you add a date field, you can search a non-event CPT by an exact date, like 8 August 2018, or a range of dates, like from 8 August 2008 to 8 August 2018.
But you cannot search by “older than today” – which changes automatically every day, only the Events CPT can do that.August 26, 2017 at 12:31 pm #393003This reply has been marked as private.August 26, 2017 at 1:30 pm #393008This reply has been marked as private.August 26, 2017 at 11:24 pm #393077Don’t confuse the expiration date of a listing [set by using the Pricing Manager] and a custom field called “expiration date”.
It is easy to manage expiration dates of listings in the backend [but they will disappear from the frontend], but you want to use a date custom field and you want to show listings with a date in that custom field on a different page on the frontend.
Both things are quite different.
Let me know if I can set this to resolved.
August 27, 2017 at 6:36 am #393096Ok I’m sorry but I’ve not solved this issue.
Actually I’m not using the Pricing Manager plugin.I’ve a listing page for each custom post type that I’ve defined, I would like to get an archive page for each custom post type.
This archive page should be based on a filtered custom field called “expiration date”.Yess, maybe I’m confusing something.
August 27, 2017 at 6:38 am #393097This reply has been marked as private.August 27, 2017 at 6:43 am #393099That is not possible out of the box.
If you add a date field called “expiration date”, you can search a non-event CPT by an exact date, like 8 August 2018, or a range of dates, like from 8 August 2008 to 8 August 2018.
But you cannot search by “older than today” – which changes automatically every day, only the Events CPT can do that.What is wrong with the Events plugin for your situation?
If you use the event date as the “expiration date”, it should do exactly what you want.August 27, 2017 at 6:46 am #393100I need to manage events too, I think that this is the problem.
Can I add two kinds of events?For example a generic events section (that is already present) and a new section based on the same custom post type?
Thanks!
AndreaAugust 27, 2017 at 6:50 am #393101Have a look at https://wpgeodirectory.com/docs/creating-different-event-types/
You cannot have 2 Event plugins, but the work around may not suit you.What you want can only be achieved with some custom code, which is not part of support.
Thanks
August 27, 2017 at 7:07 am #393103I can make a try but I’ll be happy if a developer can point me on how to modify the WP_Query that produce the listings output.
I would like an hook for functions.php file to customize the WP_Query args based on a $_POST parameter (for example) that I can manually put on the URL.
Something like this:
if ($_POST['archive']=1) { // Loop the listings with my custom $args for archive page // geodir_expiration_date <= $today ... } else { // Loop the listings with my custom $args for standard page // geodir_expiration_date >= $today ... }
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket