How do I determine if a certain term is in an array?

It depends on what kind of type are the values from your $product_terms array. If you have strings there, like term slugs, then you probably want to check if $term->slug exists. If you have objects, then make sure the array is indexed, and not associative. For associative arrays use array_key_exists() instead.

Do I have to set parent when set post term?

When you create a term for a hierarchical taxonomy, if you don’t specify a parent, its parent ID is set to 0. In other words, it becomes a parent term. Edited with regards to comments: Add specifically each term you wish to add to the post (parent terms aren’t automatically added if their children are). … Read more

setting taxonomy term to bulk posts using ids

I hope I understand this correctly. You can simply just add your post ID’s in an array and then use a foreach loop to loop through the ID’s and checking whether or not they have the term to assign or not, and if not, assign the term to the post $post_ids = [4522, 4524, 4526, … Read more

Invalid argument supplied for foreach() in search.php

Because get_the_terms will not always return an array; it will be false if the post has no terms, or a WP_Error if the taxonomy does not exist – always sanity check the result before looping: $terms_slugs = array(); $terms = get_the_terms( $post->id, ‘type’, /* Note: get_the_terms does not take a 3rd argument ==> */ array( … Read more

get_term_by “name” not working with & in name

The characters <, >, &, ” and ‘ (less than, greater than, ampersand, double quote and single quote) are enconded in term names. & becomes &amp;. This is done by passing the term object to sanitize_term() function which applies several filters. By default WordPress applies theses filters: sanitize_text_field(), wp_filter_kses() and _wp_specialchars() (see wp-includes/default-filters.php), this last … Read more

What is the term shortlink structure?

Well if you are referring to what are the query string keys are, it will depend on the taxonomy you are working with, for categories: you are looking for ?cat=cat_id tags: you are looking for ?tag=tag_slug custom taxonomy: it depends on the slug of the tax but it will look like ?taxonomy_slug=item_slug Check the definition … Read more

get_terms() for custom taxonomy related to another taxonomy

You can try getting all the posts IDs from the first taxonomy $objects = get_posts( array( ‘category’ => ‘history’, ‘numberposts’ => -1, ) ); foreach ($objects as $object) { $objects_ids[] = $object->ID; } Then get the terms from the second taxonomy associated with them: $collections = wp_get_object_terms( $object_ids, ‘collections’ );

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