Im looking for to add categories from a frontend post. I found a thread about this topic How do I create a way for users to assign categories to a post from the frontend? almost 9 years ago. There was a solution that a user created that did exactly what I was looking for but i get the following error.
Is there a better way of doing this any suggestions would be appreciated.
Uncaught Error: __clone method called on non-object in C:\xampp\htdocs\elementor_dev\wp-includes\taxonomy.php:3565 Stack trace:
#0 C:\xampp\htdocs\dev\wp-content\plugins\frontendposter.php\frontend.php(62): update_term_cache(Array)
#1 C:\xampp\htdocs\dev\wp-includes\class-wp-hook.php(287): WPSECrowdCatsClass->process_request('')
#2 C:\xampp\htdocs\dev\wp-includes\class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array)
#3 C:\xampp\htdocs\dev\wp-includes\plugin.php(478): WP_Hook->do_action(Array)
#4 C:\xampp\htdocs\dev\wp-includes\template-loader.php(13): do_action('template_redire...')
#5 C:\xampp\htdocs\dev\wp-blog-header.php(19): require_once('C:\xampp\htdocs...')
#6 C:\xampp\htdocs\dev\index.php(17): require('C:\xampp\htdocs...')
#7 {main} thrown in C:\xampp\htdocs\dev\wp-includes\taxonomy.php on line 3565
I know it has to do with these lines
// Add terms to taxonomy $affected_terms = wp_set_object_terms( $post_id, $suggested_terms, $tax, false ); update_term_cache($affected_terms); return $affected_terms;
error_log( print_r( $affected_terms, true ) );
and then looking in your error log? Maybe the inputs to wp_set_object_terms too. (it's possible you're actually getting a WP_Error back from wp_set_object_terms, but I'm not sure why that would fail to clone.)