Skip Navigation

[Resolved] gym example – create category in wp-posts autom. as i add a new gym in gym-cpt

This support ticket is created 3 years, 11 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 3 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#2070689

hi there,
hope you all are doing well.
i followed the gym and trainers ... one question came up ...
lets say i use the standard wp-posts as my blog. in there i created a parent-category called "gyms".
is it possible to get an automatically created child-category in my wp-posts as i add a new gym in the cpt for gyms ?
lets say i add a gym called 'gym001' to the cpt-of-gyms and then automatically i will get an additional child-category in my wp-posts with something like: .../category/gyms/gym001 (which will list all the 'gym001' posts).
and as this is possible, do you mind to share how this could be achieved ?
because, if so, it also should be possible to have a posts-slider under the cpt-gym .../gym/downtown-fitness-center/ that shows the latest three posts from the blog/wp-posts category of this specific gym.
hope you got my idea.
thanks in advance

klaus

#2070861

Hello,

There isn't such kind of built-in feature within Toolset plugins or WordPress.

In your case, it needs custom codes, for example, when user create a "cpt-of-gyms" post, you can use WordPress action hook save_post to trigger a PHP function:
https://developer.wordpress.org/reference/hooks/save_post/

In this PHP function, get the new post's title value:
https://developer.wordpress.org/reference/functions/get_the_title/

And use above value to add a term into taxonomy "category":
https://developer.wordpress.org/reference/functions/wp_create_term/

#2070959

Hello Luo Yang
hope you are doing fine, best wishes from Taiwan.

i see, understand your answer.
hmmm, but wouldn't make this toolset more round ?
could or maybe should this be a feature for upcoming versions ?

is it asked too much as i need a more precise example than just the links to your documentation ?

kind regards

#2072151

I hope you are fine too.

As I mentioned above, there isn't such kind of built-in feature within Toolset plugins or WordPress Core, I don't think we can implement such kind of feature.

With the structure you mentioned above, it will conducts other problem, for example, when you edit/delete a "cpt-of-gyms" post, you need to edit/delete the corresponding "category" term.