Update custom category fields front-end

the function wp_insert_term returns the newly created term id (or WP_Error on error), so once your create your term you need to store it’s ID and then you can save the “extra fields” using get_option, update_option something like: if($_SERVER[‘REQUEST_METHOD’] == “POST”) { $clientName = $_POST[“clientName”]; $term_id = $_POST[“clientName”]; $clientKeywords = $_POST[“clientKeywords”]; $clientSlug = $_POST[“clientSlug”]; $parent=””; … Read more

Avoid WP_Query’s duplicate posts with taxonomies

Pass the post ID from the first query as a post__not_in parameter to exclude it from the second query. $nature_loop_1 = new WP_Query( array ( ‘category_name’ => ‘nature’, ‘tax_query’ => array ( array ( ‘taxonomy’ => ‘highlight’, ‘field’ => ‘slug’, ‘terms’ => ‘sidebar-highlight’, ‘operator’ => ‘IN’ ) ), ) ); $exclude = $nature_loop_1->post->ID; $nature_loop_2 = … Read more

Trying to display terms from custom taxonomy within function

Function get_term_by returns object or array (based on $output arg) on success and false if failed. But you treat it as string and try to concatenate it. So your code should be following: $cat = get_term_by(‘id’, 17, ‘project_cats’); $html_content .= “<h3>” . rgpost(‘input_1’) . “</h3>”; //Title $html_content .= “<p><strong>Category:</strong> ” . rgpost(‘input_5’) . ” | … Read more

term_exists returns NULL

It can return null in some cases if you look at the code: http://core.trac.wordpress.org/browser/tags/3.3.2/wp-includes/taxonomy.php#L1492 The method get_var returns null if no result is found. If you check with “==” and not “===” that should work with false or 0.