Make taxonomy query dynamic

You can use custom field. For example, you could name it taxonomy, and then in your template, use get_post_meta() to retrieve the taxonomy: $post_id = get_the_ID(); // the ID of the current post $taxonomy = get_post_meta( $post_id, ‘taxonomy’, true ); And change the ‘taxonomy’ => ‘catmaison’ in your code to: ‘taxonomy’ => $taxonomy Example: $terms … Read more

How Do I Register Two Taxonomies with one Parent of the Other?

A taxonomy cannot be a parent/child of another taxonomy. The “hierarchical” notation indicates that you can have a hierarchy within that taxonomy. This answer addressed car Make & Model graphically. Think “category” – “subcategory” relationship. You can, however, have multiple levels of terms within a given taxonomy. If you look at the wp_insert_term() codex page, … Read more

How do i get the link of the assigned taxonomy term?

If you want to display links to each category, separated by spaces, use get_the_term_list(): <?php echo get_the_term_list( null, ‘blog-category’, ”, ‘ ‘, ” ); ?> If you have an individual term whose link you want to get, use get_term_link(): $url = get_term_link( $term );

I want to get term by term_name without taxonomy

The get_term() function does not accept a string or array; it only accepts an ID, a stdClass object or a WP_Term object. So I think you’re headed in the right direction using $wpdb. But the SQL query can’t accept a PHP array. So try this: $term_names = [‘red’,’blue’]; $term_names_str = implode(‘, ‘, $term_names); $term_datas = … Read more

Including taxonomy in searches

First you want to make the query keys available so you can check them later: add_action( ‘init’, ‘custom_add_query_vars’ ); function custom_add_query_vars() { add_query_var( ‘location’ ); add_query_var( ‘tag’ ); } Then you want to set a tax_query by filtering the WP Query: add_filter( ‘pre_get_posts’, ‘custom_search_tax_query’ ); function custom_search_tax_query() { // check this is a search query … Read more

What is the use case for sharing a term between multiple taxonomies?

The helpful folks on WordPress IRC pointed me to this article, which answered my question: https://make.wordpress.org/core/2015/02/16/taxonomy-term-splitting-in-4-2-a-developer-guide/ In WordPress 4.2, shared taxonomy terms – those items in the wp_terms table that are shared between multiple taxonomies – will be split into separate terms when one of the shared terms is updated. This change (31418) fixes one … Read more

Display related terms from a taxonomy in an entry

Please specify where are you using the code above, if in a template file or in a function. Assuming the code above is for a single post and that you’re trying to retrieve the dormitorio terms associated with that post you should use get_the_terms() instead of get_terms(). get_terms() Retrieves the terms in a given taxonomy … Read more

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