How to relate a user object to taxonomy term?

The function wp_set_object_terms relates to objects (posts, page, etc). You better use usermeta – update_usermeta. E.g update_usermeta( $user_id, ‘company’, $company_id ); WordPress is built by two major database tables (wp_posts and wp_users) and two (meta tables wp_postmeta and wp_usermeta). It seems that the term tables (wp_terms and others) relates to wp_posts. I dealing with the … Read more

Search Media by taxonomy

To search, use the s option as described in the WP_Query documentation https://codex.wordpress.org/Class_Reference/WP_Query#Search_Parameter Search Parameter Show posts based on a keyword search. s (string) – Search keyword. Show Posts based on a keyword search Display posts that match the search term “keyword”: $query = new WP_Query( array( ‘s’ => ‘keyword’ ) ); Prepending a term … Read more

Remove taxonomy widget from “PAGE” post

In your register_taxonomy() args, set meta_box_cb => false ‘meta_box_cb’ (bool|callable) Provide a callback function for the meta box display. If not set, post_categories_meta_box() is used for hierarchical taxonomies, and post_tags_meta_box() is used for non-hierarchical. If false, no meta box is shown. $args = array( //other args ‘meta_box_cb’ => false, ); register_taxonomy( $args );

Filter through custom taxonomy with an array of taxonomy IDs

First, you can’t enter such expression as second argument in get_term(). Enter directly the name of your taxonomy… Are you dealing with simple post categories? If that’s the case, your taxonomy name is ‘category’. $context[‘single_term’] = get_term( $user_terms_array[1], ‘category’ ); Second, ensure that $user_terms_array contains term IDs as integer. $user_terms_array = array_map( ‘intval’, explode( ‘-‘, … Read more

What Must to Display the “mysite.com/category” URL?

“Can be avoided this “… can’t be found”?” To answer your question in one line: YES “Is this a normal behavior?” That’s because there’s no template file setup to display at that segment of the URL structure. By default, there’s no template for domain.com/category/ however, there is a template for domain.com/category/category-name/. WordPress refers to: domain.com/category/category-name/ … Read more

How to update a taxonomy term for a custom post type with auto incrementing number

/** * Add an auto-incrementing Project ID field to Design feedback posts */ function auto_assign_ids( $post_id, $post, $update ) { // Only assign ID to new design posts if ( $post->post_status == ‘publish’ && $post->post_type == ‘designapprovalsystem’ ) { // get the most recent Project post $project_args = array( ‘numberposts’ => 2, ‘post_type’ => ‘designapprovalsystem’, … Read more

Get name of taxonomies of current page

The get_object_taxonomies function only returns the slugs of all registered taxonomies to that post type, so you’re almost there. You need to actually go get the taxonomy itself using get_taxonomy() … foreach ( $taxonomies as $taxonomy ) { $tax_object = get_taxonomy( $taxonomy ); $out .= “<li’><span’>” . $tax_object->name . “: “; $out .= “</span>”; …

How to get terms from a custom taxonomies after WordPress 4.5.0

OK, wild guess: $prefix_topic_terms= array(); if ( ! empty( $iva_topic_terms ) ) { vs $prefix_topic_terms = array(); if ( ! empty( $prefix_topic_terms ) ) { You’ve changed the variable that is checked for emptiness in the new code. That code will never query get_terms for that taxonomy, because $prefix_topic_terms will not be empty. The Error-object … Read more

Corrupted nav-menu?

Sounds like you deleted some terms and/or taxonomies related to menus. You need to get those back into the database. Easiest solution is if you took a database backup before removing those terms, as is best practice, just restore your database. Or if the host provides automated backups, use one of those. If you don’t … Read more