Taxonomy Checkbox Admin Panel

Change the name of the checkboxes fromfirm to firm[]. Then, when you go to save the checkboxes $terms = $_POST[‘firm’]; will give you an array of term slugs that can be checked/sanitized prior to using wp_set_object_terms to add the terms… wp_set_object_terms( $user_id, $terms, ‘firm’, false);

Get_the_term_list inexplicably adds values in foreach

The problem lies with the get_the_term_list() function, which is defined with the following arguments: get_the_term_list( $id = 0, $taxonomy, $before=””, $sep = ”, $after=”” ) You’re defining the $before argument as true which PHP prints as 1 so that’s why it’s printing a 1 before the list. You should either remove the argument altogether: get_the_term_list( … Read more

How to check if a term is parent to another?

You can use wp_list_categories() where the hierarchical argument is set to true by default , something like this: <div class=”produkt_nav”><h3><a href=”https://wordpress.stackexchange.com/produkter/”>Produkter</a></h3> <ul> <?php wp_list_categories(‘taxonomy’ => ‘kategori’); ?> </ul> </div>

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.