Correct way to insert taxonomies on page insert

Turns out you can’t use the term slug (for obvious reason of possible duplicate slugs face palm) you need to use the terms ID. $term_id = term_exists( ‘system’, ‘status’ ); $page = array( ‘post_title’ => ‘New Job’, ‘post_name’ => ‘new-job’, ‘post_content’ => ”, ‘post_status’ => ‘publish’, ‘post_author’ => 1, ‘post_type’ => ‘jobs’, ‘tax_input’ => array … Read more

Get taxonomy parent using child slug (from merged taxonomies)

Since in most cases I would need to now the ‘taxonomy’, one work around I found (actually, pointe by @Howdy_McGee) was to pass the slug of the term and it’s parent to the value, and then split-string. Here is my final code: foreach ($tax_categorias as $tax_categoria) { echo ‘<option value=”. $tax_categoria->slug .”.’. $tax_categoria->taxonomy .” . … Read more

How Can I Change a Taxonomy URL Based On The Originating URL?

The term_link filter has a different signature for its callback function than the page_link filter, meaning the arguments in your callback are different. (Also note you’ll need to explicitly set the argument number when you call add_filter because by default add_filter will only setup 1 argument. For example: add_filter( ‘term_link’, ‘lqd_series_link’, 10, 3 ); // … Read more

List taxonomies according to whether this post is in another taxonomy in taxonomy archive

Well I got there, my public brain functions for all to see, hopefully someone somewhen will pass this was and find it useful. The code; // First get the type $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); $type = $term->slug; // we need to do some comparisons, here’s the variable $this_instance … Read more

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

Filter WooCommerce admin products list by a custom taxonomy

There is some missing parts in your code: Try the following: add_action(‘restrict_manage_posts’, ‘admin_products_by_manufacturer_filter_dropdown’); function admin_products_by_manufacturer_filter_dropdown() { global $typenow, $pagenow; $taxonomy = ‘vyrobca’; // The custom taxonomy if( ‘edit.php’ === $pagenow && ‘product’ === $typenow && taxonomy_exists( $taxonomy ) ) { $info_taxonomy = get_taxonomy($taxonomy); $selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : ”; wp_dropdown_categories( array( ‘show_option_all’ => sprintf( … Read more

Sorting Tags by Slug Value

You can set orderby slug like : $tags = get_tags( ‘order=ASC&orderby=slug’ ); $html=”<div class=”post_tags”>”; foreach ( $tags as $tag ) { $tag_link = get_tag_link( $tag->term_id ); $html .= “<a href=”https://wordpress.stackexchange.com/questions/340357/{$tag_link}” title=”{$tag->name} Tag” class=”{$tag->slug}”>”; $html .= “{$tag->name}</a>”; } $html .= ‘</div>’; echo $html;

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