Skip Navigation

[Resolved] save_post hook to automatically set the taxonomy based upon the date field when

This support ticket is created 3 years, 7 months ago. 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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 3 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#2181599

I there,

I read that there is a solution, but I can't find it here.
I have a date field in backend but i want to filter the posts in frontend with only the year. I don't want a datepicker.
Is thewre a solution to automatically set the taxonomy based upon the date field's year whenever a post was saved in backend?

Kind regards, Alex

#2181803

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

There is no automatic way to do that but you can workaround it by using the default WordPress hook "save_post" and extract the year from the date and set it as taxonomy term.

Please check the following Doc:
https://toolset.com/documentation/customizing-sites-using-php/updating-types-fields-using-php/

You will have to adjust the code for save_post hook as per your requirement. If you do not know how to do that, Please share admin access details and all required information like what date field you want to target and to what taxonomy you want to add it a new term.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.