New answers tagged


Try this code after the $bio = wp_insert_post( $my_bio_post ); line: $terms = isset($_POST['my_pet']) ? array_filter($_POST['my_pet']) : 0; if ($terms && $bio) wp_set_object_terms($bio, $terms, 'Cats'); See wp_set_object_terms() for more info and make sure the Cats taxonomy and the terms in your checkboxes is already available.


The problem ended up being the hook after_setup_theme. I was effectively invoking the function by refreshing the browser which launches the hook in both Javascript and PHP so the hook was being triggered more than once when the browser was refreshed. Once I disabled Javascript everything worked fine. Another solution would have been to use a different hook ...


You can use the get_page_by_title() function of WordPress: <?php $postTitle = $_POST['post_title']; $submit = $_POST['submit']; if(isset($submit)){ $customPost = get_page_by_title($postTitle, OBJECT, 'stuff'); if(!is_null($customPost)) { $meta = get_post_meta($customPost->ID, 'times', true); $meta++; ...

Top 50 recent answers are included