Problem:
The problem here is that the user wanted to assign a default category to their post when the post is submitted.
Solution:
You can assign a default taxonomy to a post using the hook below.
function set_default_category($post_id) { if ( ! has_term('', 'genre') && get_post_type($post_id) == 'post' ) { wp_set_object_terms( $post_id, 'funk', 'genre'); } } add_action( 'save_post', 'set_default_category' );
Add the function to your Toolset custom codes in Toolset -> Settings -> Custom Code and activate it.
You will need to replace 'post' with the slug of your custom post type, 'funk' with the taxonomy term slug and 'genre' with the taxonomy slug.
Once you've done this then whenever your users create a post with no taxonomy assigned then one will automatically get assigned.
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 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
This topic contains 4 replies, has 2 voices.
Last updated by 3 years, 10 months ago.
Assisted by: Shane.