Looping Through Custom Tax Terms and Displaying All Posts For Each

If your things are laid properly, this code will output 10 posts from film CPT, where taxonomy is category-film and it will occur each of the term of that particular taxonomy. I’m not aware about your templating, so lay your layout accordingly. <?php $_terms = get_terms( array(‘category-film’) ); foreach ($_terms as $term) : $term_slug = … Read more

WP_insert_term how to insert multiple values as taxonomny term?

I would build the input fields for terms as array of inputs. Like this (note the [] inthe name attribute: <input name=”input_name[]” type=”text” value=””> <input name=”input_name[]” type=”text” value=””> <input name=”input_name[]” type=”text” value=””> Then, in PHP: //Now $_POST[‘input_name’]; is an array //get the array and sanitize it $input_terms = array_map( ‘sanitize_text_field’, $_POST[‘input_name’] ); //Set the array … Read more

Conditional two level dropdown filter for custom post type

Like I said in the comment, this can be solved by using two dropdowns. Additionally I already hinted you to an answer of mine doing this for a simple, one level, non conditional category selection. Category dropdowns can easily constructed with wordpress by making use of wp_dropdown_categories. To make it work as actual selection handed … Read more

Custom post type category, taxonomy and URL rewrite problem

Welcome to WPSE. That can be solved pretty straight forward. Register a custom post type products Register two taxonomies (brands and functionalities) for your custom post type Feed WordPress the correct template, following the template hierarchy and WordPress standard Flush your rewrite rules (can’t be skipped, but is easy) Step 1 Register your custom post … Read more

Add filter to wp_list_categories and query what type of taxonomy-terms it use?

WordPress do: apply_filters( ‘wp_list_categories’, $output, $args ); You can do: function add_slug_css_list_categories($list,$args) { } Then you can use $args to determine what kind of list you have. Not sure if you must do that but when you add the filter there is also a variable for accepted arguments: add_filter(‘wp_list_categories’, ‘add_slug_css_list_categories’,10,2);

Automatically assign a custom post to a custom taxonomy based on custom field value

I’m sure this not best answer, however you may try like this add_action(‘save_post’, ‘add_my_taxonomy’); function add_my_taxonomy($post_ID) { $area = array( ‘ny’ => ‘New York’, ‘la’ => ‘Los Angeles’ ); $zip = array( ‘ny’ => ‘10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009, 10010, 10011, 10012, 10013, 10014, 10015, 10016, 10017, 10018, 10019, 10020, 10021, … Read more