Term count by user

It’s a little bit hard to guess, what are you trying to do exactly, but let me try to answer… My best guess is that you want to tell, how many properties has given user published in given property type. So first – why your code doesn’t work… get_term will get the term info and … Read more

Use get_the_terms to list subcategories of custom taxonomy

When you use get_the_terms() it returns a term object. One of the fields is ‘parent’ which stores the ID of the term parent. So you can compare the current term’s parent to the parent term that you are looking for. $desired_parent_name=”fruits”; $desired_parent_id = get_term_by(‘name’, $desired_parent_name)->term_id; foreach ($terms as $term) { if $term->parent == $desired_parent_id { … Read more

Print terms with taxonomy and metabox value

Try This: $args = array( ‘hide_empty’ => false, ‘relation’ => ‘OR’, array( ‘key’ => ‘serial_language’, ‘value’ =>’english’, ‘compare’ => ‘LIKE’ ), array( ‘key’ => ‘serial_language’, ‘value’ =>’arabic’, ‘compare’ => ‘LIKE’ ), ‘taxonomy’ => ‘serial’, ); $terms = get_terms( $args ); hope this will help

WordPress User Taxonomy Saved Values

There are two errors in your code. First one is the inconsistency in field names. Here’s your checkbox field: <input type=”checkbox” name=”competence-<?php echo esc_attr( $term->slug ); ?>” id=”competence-<?php echo esc_attr( $term->slug ); ?>” value=”<?php echo esc_attr( $term->slug ); ?>” <?php checked( true, is_object_in_term( $user->ID, ‘competence’, $term ) ); ?> /> And here’s the part you’re … Read more

how to get URL of media uploaded to WordPress via media_handle_sideload()

To get the URL of the uploaded image/attachment, you can use wp_get_attachment_url() (which always returns the full-sized image URL) or wp_get_attachment_image_url() for image attachment: // This is how you should call uploadImageToMediaLibrary(); assign the value to $att_id. $att_id = uploadImageToMediaLibrary($post->ID, $external_url, “custom_alt”); $url = wp_get_attachment_image_url( $att_id, ‘full’ ); // full-sized URL But to set the … Read more

Query all posts of a custom taxonomy term

I believe your issue is with understanding the nature of posts’ hierarchy vs pages’ hierarchy. A page is a type of “post”. It can have hierarchical structure. Posts, by default, do not have hierarchy. So, you would not be able to get post-parents without their children, because the system does not recognize a hierarchy. This … Read more

get_terms adds slaces to the resualt

What you’d need to do is double-escape, so change echo ‘\” . $term->name . ‘\’, ‘; to echo ‘\\\” . $term->name . ‘\\\’, ‘; …but, you’d be much better off just using different encapsulators: <select class=”w-100″ name=”mf_term”> <option value=” <?php $terms = get_terms( ‘call-type’ ); if ( ! empty( $terms ) && ! is_wp_error( $terms … Read more