term/tag not being saved for custom post type
wp_set_post_terms only works with the post post type, use wp_set_object_terms for all post types.
wp_set_post_terms only works with the post post type, use wp_set_object_terms for all post types.
Notice: completely update code after OP update answer. Assuming you want to update in front-end the taxonomy ‘post_tag’ (the standard tags) fro standard post and a taxonomy called ‘research-sections’ for a custom post type called ‘research’. Probably you have to put the form in both single.php and single-research.php and in both you have to some … Read more
You need to first define the $settings and the $editor_id and the $content variables. Then you can call wp_editor(). Something like this should work for you: // default settings $content=”This content gets loaded first.”; $editor_id = ‘my_frontend_editor’; $settings = array( ‘wpautop’ => true, // use wpautop? ‘media_buttons’ => true, // show insert/upload button(s) ‘textarea_name’ => … Read more
I see two problems with your code: First You named your custom taxonomy type which is a Reserved Term Second You are trying to insert your taxonomy terms using ‘post_category’ which wont get the job done. What you can do is either create a `’tax_input’ => array(‘ in your new post array e.g: $new_post = … Read more
It’s few months already and you probably have this solved by now but I’ll try to do a little necromancing resume here anyway. We don’t like unanswered questions right? 😉 There’s a recent topic dealing with the front-end login & registration: Front-end Register Form You can change what WordPress displays to the users based on … Read more
I checked and it works with this: $new_post = array( ‘post_content’ => $_POST[‘post-content’], ‘post_title’ => wp_strip_all_tags( $_POST[‘post-title’] ), ‘post_type’ => ‘custom_pt’ ); note: I used a text input for the single category <input id=”input-name-value” name=”input-name-value” type=”text” /> I havent tried it with a select – option dropdown. or more than 1 category. $post_id = wp_insert_post( … Read more
Your code doesn’t show if and how you set $terms other then that its seems ok, just try to wrap it in an array and you should check if its set first, so try this: $new_post = array( ‘post_author’ => $user_id, ‘post_title’ => $post_title, ‘post_content’ => $post_content, ‘post_category’ => array($_POST[‘cat’]), ‘tags_input’ => array($tags), ‘post_type’ => … Read more
I’ve found the issue but don’t know why it was giving me the error establishing a database connection. But it’s fixed by changing entries in three tables what happened was that moved WordPress to new server with different domain and there were instances of the old domain. Thank you!
I believe Front End Editor calls wp_update_post, which in turn calls wp_insert_post. You should be able to hook either save_post or wp_insert_post for new/updated posts, and edit_post or post_updated for updated posts.
The context of your code that fails isn’t entirely clear, but it’s failing because get_the_ID() won’t return a post ID when run on the init hook, because the main query hasn’t been executed yet. If you have a look at the Action Reference, wp is the earliest action where you can access the current query’s … Read more