has_term not working

You mention in a previous comment that you are defining $post directly before the conditional statements. Since this is the case you need to pass the $post object to both these functions to get desired results otherwise WordPress will attempt to use the global $post object which isn’t what you’ve defined and thus throwing errors … Read more

WordPress REST get all items without a taxonomy assigned

I was able to solve the problem by adding a custom route. Although i had to do the same process in php by first querying all available terms of the type and then exclude them from the query. $available_terms = array_map( function ( $term ) { return $term->term_id; }, get_terms( ‘lagerboxen_kategorie’ ) ); return get_posts( … Read more

Conditional tag affecting taxonomy term and its children?

I have a handy little function that i based on post_is_in_descendant_category function it expends the is_tax to check if its the term or any of his children function is_or_descendant_tax( $terms,$taxonomy){ if (is_tax($taxonomy, $terms)){ return true; } foreach ( (array) $terms as $term ) { // get_term_children() accepts integer ID only $descendants = get_term_children( (int) $term, … Read more

Get current custom user taxonomy

Try this suggestion: $user_id = get_current_user_id(); // Get current user Id $user_groups = wp_get_object_terms($user_id, ‘user-group’, array(‘fields’ => ‘all_with_object_id’)); // Get user group detail foreach($user_groups as $user_gro) { echo $user_gro->name; // Get current user group name echo $user_gro->taxonomy; // get current user taxonomy }

base directories / URL

You can manually create pages named category and app in admin under the Pages menu, and use a custom page template for each to list out taxonomy terms or whatever you need. EDIT – 301 redirect a request that matches the pagename rewrite to another page: function wpa_parse_query( $query ){ if( isset( $query->query_vars[‘pagename’] ) && … Read more

Unable to delete a Category and Tag that share same slug

The problem is WordPress database schema for taxonomies. In database, two terms in 2 different taxonomies with same slug share the same row on terms table. They are differentiate with 2 rows on the terms_taxonomy table. So if you want to delete only the category, you have to perform a custom sql on WordPress database. … Read more

Get and loop posts with all taxonomy terms

Your best option will be to get an array of term ids by using get_terms which belongs to the authors taxonomy and then using that as your array of terms in your tax_query The following requires PHP5.4+ $term_ids = get_terms( ‘authors’, [‘fields’ => ‘ids’] ); // Only get term ids $args = [ ‘tax_query’ => … Read more

functions to create term and child terms

To create a taxonomy, you should use register_taxonomy(). This function accepts three arguments: <?php register_taxonomy( $taxonomy, $object_type, $args ); ?> The documents on the codex are plenty self explanatory. Now, to insert a term into a taxonomy, you can use wp_insert_term(). Again this function accepts 3 arguments: <?php wp_insert_term( $term, $taxonomy, $args = array() ); … Read more

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