Skip Navigation

[Resuelto] Add expiration to posts

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:
Can we make posts expire somehow with Toolset?

Solution:
You can use Toolset Forms to add the expiration to the posts.
https://toolset.com/documentation/user-guides/automatic-post-expiration/

This allows to set the post (if created through Toolset Forms) to another post state after a certain time is passed.

It does not allow to update custom fields or there like - for that custom code would be needed. However usually the post status is enough to "let a post expire".

This support ticket is created hace 5 años, 1 mes. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Etiquetado: 

Este tema contiene 6 respuestas, tiene 2 mensajes.

Última actualización por bastienB hace 5 años, 1 mes.

Asistido por: Beda.

Autor
Mensajes
#1340267

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!

#1340347

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.

#1341449

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

#1341809

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

#1342419

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

#1342607

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.

#1343423

My issue is resolved now. Thank you!