Creating categories while importing via CSV

I was able to solve this by checking if the term exists, and then using tax_input in wp_insert_post() // Check if the category exists $category_term = term_exists(trim($category), ‘formula_types’, 0); // Create category if it doesn’t exist if (!$category_term) { $category_term = wp_insert_term(trim($category), ‘formula_types’, array(‘parent’ => 0)); } array_push($formattedCategories, (int)$category_term[‘term_taxonomy_id’]); $post = array( ‘post_title’ => $results[‘drug_name’], … Read more

how to create a category with wp_insert_post and post_category

In order to add existing term or new term to post you need to use wp_set_post_terms by checking with term_exists and using wp_insert_term if it doesn’t. Something like this: $author_id = 1; $slug = ‘wordpress-post-created-with-code’; $title=”WordPress post created whith code”; $content=”This is the content of the post that we are creating right now with code. … Read more

wp_insert_post deleting previous post custom meta

SOLVED… for now I think this code was my problem: // use reset postdata to restore orginal query wp_reset_postdata(); if ( $current_slug == $approve_slug && $success === 1 && isset ($success) ) { $next_pay_stub_id = create_next_pay_stub( $term->term_id ); } } //this is the closing bracket of my foreach statement which I changed to if ( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)