Tell us what you are trying to do? I want to set an expiration date to a CPT "Promotion", once this date has passed, I want the post to be moved from the archive to an "Expired" section.
The archive URL is: enlace oculto
The expired archive URL would be: enlace oculto
Is there any documentation that you are following? No.
Is there a similar example that we can see? Not that I'm aware of.
What is the link to your site? enlace oculto
--
We have added the expiration date as a custom field for each post. I know we can add a query filter so that only the posts that have the custom field as a DATE that is LOWER THAN TODAY are displayed.
The next bit is where I'm unsure how to proceed... I guess I could create a Page with the name "Expired" and have a View configured so that I can output the expired promotions there but how would I use the URL "enlace oculto" ?
Thank you for your help!
You can use Toolset Forms to add the expiration to the posts.
https://toolset.com/documentation/user-guides/automatic-post-expiration/
You can tell Toolset to set the post for example as a draft after it expires, and then in a View, you can query either expired or not expired posts - either by different post states or even by the expiration date (which is stored in a custom field).
Archive URL's however do not work like outlined above.
Archive URL's are always unique, and there are never more than one each type.
So in your case, you will have access to an /promotions/ archive, but you cannot have an archive /promotions/whatever.
That would maybe require a separate page and view, instead.
So you could add a query filter to the archive in Toolset > WordPress archives to exclude all posts that are expired (by date, or state).
Then, in a View, you can query the post type but exclude all posts that are not yet expired (by date or state)
Please let me know if you'd need more details here.
Hello Beda,
Thank you for the suggested approach and link to the automatic post expiration documentation.
We do not necessarily want posts to become un-reachable (status changed to "draft") after expiration, hence why we have an "Expired" section. Promotions should still be visible for reference but in a separate section.
I also understand that we can't have "nested" archives.
So your suggestion to use a separate page and view is the exact approach I was considering. I'm just unsure how to have that page under the /promotions/ slug. If you could guide me to achieve that would be fantastic!
Thanks again.
All best,
B
To have a page with that slug where you can have lists of contents you simply need to create such page.
If the slug is used for a post type, you cannot use the same slug: this is a WordPress restriction.
A solution usually is to rename the page to something link "post-type-slug-anystring-here" if you want the page to match the post type to the closest possible.
You cannot have the same slug as the type itself, as that is A) the Archive and B) the post type itself
Please let me know if something remains unclear
Hey Beda,
Thanks for the additional information.
I understand I'm playing with WordPress limitations here so I'll have to find a different approach if I want to keep "/expired" as a child page of "promotions".
Assuming the CPT slug has no singular/plural and I enter "promotion" in both fields... Would that work?
Then I can have an actual page with the slug "promotions" and a child page "promotions/expired" where I use different Views to output the results?
Let me know if that sounds workable.
All best,
B
It's not suggested to have the same singular and plural slug.
You can actually find here an instruction about how to let the page have precedence over the archive:
enlace oculto
But note, that means precedence - the archive won't work.
In the other case, the archive has precedence and the page won't work.
I suggest to keep things "unique". Look at the slugs as kind of ID's, rather than titles.
My issue is resolved now. Thank you!