Assign automatically a category to an attachment on upload
-
Hello,
My website structure is really complex. In short, here is what I have done and what I want to do.
I. What I have successfully done…
For each of my products, I have a related forum with its own post type (cma_thread) and category (cma_category). Each time I publish a post for a product, its related post on the forum (a standard ‘Please read this post before submitting in this forum’) is automatically created and set to a category which is the post title, sanitized. Everything is done with an “add_action on save post”.
II. What I can’t actually achieve…
Kinda the same process for my 4 featured images per post. Because each image is published as an “attachment” post type, and since I have added the category support, I just have to assign a category (the sanitized title, again) for the 4 featured images.
But the problem here is that no title are defined until I save first my post. And this means I can’t assign a function on “save_post”.
Then, I have probably to add an action on upload or something similar… but I’m really stucked actually. Do you guys have some tips to give me on the way to proceed?
Regards.
- The topic ‘Assign automatically a category to an attachment on upload’ is closed to new replies.