wp_set_object_terms doesn’t work

This is the solution function add_tags_products() { global $product; $args = array( ‘post_type’ => ‘product’, // your product post type ‘posts_per_page’ => – 1, ); $posts = get_posts($args); foreach ($posts as $post): setup_postdata($post); // check to see if the post has any tags if( ! has_term( ”, ‘product_tag’, $post->ID ) ) : // create the … Read more

Can we apply hide empty to get_the_terms?

hide_empty hides terms that have no posts attached to them. You’ve got a page with no ht_kb_tags attached to it, if I’m understanding the question correctly. Since get_the_terms() returns false if there are no terms, you should be able to prevent the foreach() with an if() statement: $mget_site_url = get_site_url(); //This gets me all the … Read more

get_terms_args ordering by meta key not working

After a lot of searching and tests… Finally I’ve found a solution. Instead using get_terms_args filter, I’ve changed to parse_term_query action. My resulting code looks this way now: add_action(“parse_term_query”, “MyTheme_ParseTermQuery”, PHP_INT_MAX, 1); function MyTheme_ParseTermQuery(&$query) { $taxonomy = $query->query_vars[‘taxonomy’][0]; if($taxonomy == “edition”){ $query->query_vars[‘order’] = “ASC”; $query->query_vars[‘orderby’] = “meta_value_num”; $query->query_vars[‘meta_query’] = [[ ‘key’ => “_edition”, ‘type’ => … Read more

Customizing the wordpress tag-cloud output

This is how the links are created in wp_generate_tag_cloud (wp-includes/category-template.php) foreach ( $tags as $key => $tag ) { $count = $counts[ $key ]; $real_count = $real_counts[ $key ]; $tag_link = ‘#’ != $tag->link ? esc_url( $tag->link ) : ‘#’; $tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key; $tag_name = $tags[ $key … Read more

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