Using get_terms() to list terms from one custom taxonomy AND from one specific built-in category

Well, I do not know if this is quite OK, but is returning the expected results … so at the moment this it is enough for me. function my_custom_get_terms( $my_tax, $my_category, $show_all = true ){ global $wpdb; global $pagename; $query = “SELECT Count(wp_posts.ID) AS my_term_count, wp_term_taxonomy.term_taxonomy_id, wp_term_taxonomy.taxonomy, wp_terms.name, wp_terms.term_id, wp_terms.slug AS term_slug, wp_terms.term_group, wp_terms_1.slug FROM … Read more

Display Child Categories of Current Post ID

For actual categories: <ul> <?php global $post; // grab categories of current post $categories = get_the_category($post->ID); // define arguments of following listing function $args = array ( ‘child_of’ => $categories[0], // current post’s (first) category ‘title_li’ => ” // disable display of outer list item ); // list child categories wp_list_categories($args); ?> </ul> The same … Read more

Bug using wp_insert_term with switch_to_blog

Hook into ‘pre_insert_term’, $term, $taxonomy and dump the global $blog_id; to see if you’re on the right place: function wpse_inspect_blog_id( $term, $taxonomy ) { global $blog_id; var_dump( $blog_id ); exit; } function wpse_hook_inspector_blog_id() { add_filter( ‘pre_insert_term’, ‘wpse_inspect_blog_id’ ); } add_action( ‘init’, ‘wpse_hook_inspector_blog_id’ );

Most allowed Taxonomies in Appearance->Menus

Whilst the menu system is great, it is a little intensive; 300 is obviously pushing it. Would a code snippet not be the way to go? <ul class=”places”> <?php wp_list_categories( ‘taxonomy=places&title_li=’ ) ?> </ul>

Retrieve all term IDs of post

Try out this code and see if it works for you, I just cooked it up real quick and haven’t tested it, so it may be way off base, but the concept is there. $tax_args = array( ‘public’ => true ); $taxonomies = get_taxonomies( $tax_args, ‘names’, ‘or’ ); $term_args = array( ‘fields’ => ‘ids’ ); … Read more

Taxonomy Checkbox Admin Panel

Change the name of the checkboxes fromfirm to firm[]. Then, when you go to save the checkboxes $terms = $_POST[‘firm’]; will give you an array of term slugs that can be checked/sanitized prior to using wp_set_object_terms to add the terms… wp_set_object_terms( $user_id, $terms, ‘firm’, false);

Get_the_term_list inexplicably adds values in foreach

The problem lies with the get_the_term_list() function, which is defined with the following arguments: get_the_term_list( $id = 0, $taxonomy, $before=””, $sep = ”, $after=”” ) You’re defining the $before argument as true which PHP prints as 1 so that’s why it’s printing a 1 before the list. You should either remove the argument altogether: get_the_term_list( … Read more

How to check if a term is parent to another?

You can use wp_list_categories() where the hierarchical argument is set to true by default , something like this: <div class=”produkt_nav”><h3><a href=”https://wordpress.stackexchange.com/produkter/”>Produkter</a></h3> <ul> <?php wp_list_categories(‘taxonomy’ => ‘kategori’); ?> </ul> </div>