Set post terms by term id

When dealing with this, it turned out that the $parent var had to be casted as an int. Looking at the function wp_set_object_terms, it tests the param $parent with is_int(). The var $parent was coming from $_POST which was sent though http post using ajax. Somewhere along the way, probably on the javascript side, my … Read more

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