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
  • Author
    Posts
  • #392985

    Andrea Piaggesi
    Expired Member
    Post count: 42

    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!
    Andrea

    #392989

    Guust
    Moderator
    Post count: 29970

    Use these automatic URLs:
    /events/?etype=past
    /events/?etype=upcoming

    On the events page, you can select from past, future, today and all.

    Thanks

    #392991

    Andrea Piaggesi
    Expired Member
    Post count: 42

    Thanks 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.
    Andrea

    #392996

    Guust
    Moderator
    Post count: 29970

    You do not have to use Events, but it the only CPT that can be sorted like you want.

    #393001

    Andrea Piaggesi
    Expired Member
    Post count: 42

    Hi,
    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.
    Andrea

    #393002

    Guust
    Moderator
    Post count: 29970

    If 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.

    #393003

    Guust
    Moderator
    Post count: 29970
    This reply has been marked as private.
    #393008

    Andrea Piaggesi
    Expired Member
    Post count: 42
    This reply has been marked as private.
    #393077

    Guust
    Moderator
    Post count: 29970

    Don’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.

    #393096

    Andrea Piaggesi
    Expired Member
    Post count: 42

    Ok 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.

    #393097

    Andrea Piaggesi
    Expired Member
    Post count: 42
    This reply has been marked as private.
    #393099

    Guust
    Moderator
    Post count: 29970

    That 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.

    #393100

    Andrea Piaggesi
    Expired Member
    Post count: 42

    I 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!
    Andrea

    #393101

    Guust
    Moderator
    Post count: 29970

    Have 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

    #393103

    Andrea Piaggesi
    Expired Member
    Post count: 42

    I 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 ...
    }
Viewing 15 posts - 1 through 15 (of 23 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount