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>

Taxonomy Drop Down with hierarchical view using $terms

I can kick myself, been struggling for 2 days and all that I had to do to make the wp_dropdown_categories option work is change the name to the same value as the taxonomy. My complete working code is: <?php // Equipment Category Dropdown, thanks https://gist.github.com/2902509 class Walker_SlugValueCategoryDropdown extends Walker_CategoryDropdown { function start_el(&$output, $category, $depth, $args) … Read more

Problem retriving the post type category

get_terms retrieves all terms in a taxonomy, not terms added to a post. you want to use get_the_terms to retrieve terms assigned to a specific post. there are no additional arguments to filter the list of terms returned, you’ll have to manually check a term’s parent to only output terms that are a child of … Read more

Get fuzzy matches from get_term_by

There’re several questions you should ask yourself: #1) Are the “language codes” actually ISO 639-2 compatible? Stephen Harris and me build a list of all available ISO 639-2 language codes – [available on GitHub on the WeCodeMore-Label account] – that should be used. This is the official list (build from the official ISO source). In … Read more

Trying to use wp_set_object_terms while supplying an array for both term id, and texonomies

what i ended up doing: foreach($this->parents as $parent){ $taxonomies[] = $parent[‘app_name’]; } wp_delete_object_term_relationships( (int)$parent[‘item_id’], array_unique( $taxonomies ) ); foreach($this->parents as $parent){ $cat_id = (int)$parent[‘item_id’]; $taxonomy = $parent[‘app_name’]; wp_set_object_terms( (int)$parent[‘item_id’], $cat_id,$taxonomy, true); } This solution is a little longer but it worked and i couldn’t spend more time searching the problem. Thanks

Set unique term_id from custom meta keys

The last (fourth) argument that you pass to wp_set_object_terms() is true, which, “If true, tags will be appended to the object. If false, tags will replace existing tags”. It sounds as though you are instructing wp_set_object_terms() to do, if I understand you, exactly what you don’t want it to do. I think that you need … Read more

Get Custom Post Child Term

Try this may be help you. $terms = get_the_terms($post->ID, ‘section’ ); echo ‘<ul>’; foreach ($terms as $term) { $term_slugs_arr[0] = $term->name; $termchildren = get_term_children( $term->term_id, ‘section’ ); foreach ( $termchildren as $child ) { $term = get_term_by( ‘id’, $child, $taxonomy_name ); echo ‘<li><a href=”‘ . get_term_link( $child, $taxonomy_name ) . ‘”>’ . $term->name . ‘</a></li>’; … Read more

INSERTING Data into table with placeholders

I found the answer, in the codex. I just used it’s code and adapted it, this code: $wpdb->query( $wpdb->prepare( ” INSERT INTO $wpdb->postmeta ( post_id, meta_key, meta_value ) VALUES ( %d, %s, %s ) “, 10, $metakey, $metavalue ) ); So it works now.

If product is in sub-category show code

You can probably just make use of has_term( $term, $taxonomy, $post ) which will check if the specific post belongs to the term given You can do something like this (Edit: Add post ID if this is used in a function) global $post; if(has_term( ‘lucha’, ‘product_cat’, $post->ID )) { //do something if post has lucha term }else{ //do something … Read more

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