WordPress implode & wp_insert_post question

The second parameter to wp_set_object_terms() takes an array, integer, or string. (array/int/string) (required) The slug or id of the term (such as category or tag IDs), will replace all existing related terms in this taxonomy. To clear or remove all terms from an object, pass an empty string or NULL. Integers are interpreted as tag … Read more

Search Query for Multiple Terms In Same Taxonomy

You need to make only one change in the form, change the first line to: <select name=”property_type[]” class=”form-control” multiple> Name of the field has to include [] to be considered as an array when it arrives on the server side. In the query string it will be listed as: property_type[]=condo&property_type[]=duplex And, on server side, when … Read more

Count Number of Posts in Taxonomy Term in Last 24 Hours

You can create a custom WP_Query and count its result. $wp_query = new WP_Query([ ‘tax_query’ => [ [ ‘taxonomy’ => ‘news’, ‘terms’ => $term_name, ‘fields’ => ‘name’ ] ], ‘date_query’ => [ [ ‘after’ => ’24 hours ago’ ] ] ]); $number_of_posts = $wp_query->found_posts; Edit I removed posts_per_page argument, as @birgire suggests, that found_posts offers … Read more

How do I return all terms from multiple taxonomies?

You have all sorts of fun questions today! There is also a WP_Term_Query available in WordPress. Here is some info on it as well as what parameters you can pass it. https://developer.wordpress.org/reference/classes/WP_Term_Query/__construct/ $term_args = array( ‘taxonomy’ => array(‘tax_one’, ‘tax_two’, ‘tax_six’), ‘hide_empty’ => false, ‘fields’ => ‘all’, ‘count’ => true, ); $term_query = new WP_Term_Query($term_args); foreach … Read more

get_terms() duplicate first term of a custom taxonomy

I think you want to show list of the category links right? but you are echo list inside the for-each loop. you have to write that outside of the loop. foreach ($terms as $term) { $term_list .= ‘<a class=”related-market btn btn-outline-secondary” href=”‘ . esc_url(get_term_link($term)) . ‘”>’ . $term->name . ‘</a>’; } echo $term_list; Also don’t … Read more

Taxonomy Parent Name

<?php $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); $parent = get_term_by( ‘id’, $term->parent, get_query_var( ‘taxonomy’ ) ); if($parent): echo $parent->name; endif; ?>