Calling mysql_query() on another database, assumes WordPress using that database

Use a new instance of wpdb to connect and read from the other database: $mydb = new wpdb(‘blah’,’blah’,’dkpldump’,’localhost’); $event_categories = $mydb->get_results(“SELECT * FROM calendar_cats”); foreach( $event_categories as $event_category ){ //create term! $term = wp_insert_term( $event_category->categoryId, ‘event_category’, array( ‘slug’ => $event_category->categoryName ) ); }

Show all videos by tag name

Try this. Use for tag_id in get_posts. $tax_terms = get_terms(‘media_category’, ‘orderby=count&order=DESC&hide_empty=0’); foreach ( $tax_terms as $tax_term ) { $posts = get_posts(array( “meta_key” => ‘select’, “meta_value” => 1, “tag_id” => 5, “post_mime_type” => “video”, “taxonomy” => $tax_term->taxonomy, “term” => $tax_term->slug, “numberposts” => 100, “posts_per_page” => 100));

Removing a taxonomy term

Your issue is last argument in wp_set_object_terms() call. You are setting $append to true, so it essentially checks if input is already present and does nothing else. You want it set to false (which is also default) so that terms are forced to be same as input and difference (what you removed) is deleted from … Read more

Set unique term_id from custom meta keys

The last (fourth) argument that you pass to wp_set_object_terms() is true, which, “If true, tags will be appended to the object. If false, tags will replace existing tags”. It sounds as though you are instructing wp_set_object_terms() to do, if I understand you, exactly what you don’t want it to do. I think that you need … Read more

Exclude categories by ID

You could try modifying your query such that you have an array of categories to exclude and a conditional in the foreach, working similarly to the !empty(). An untested example: <!– category list with thumbs –> <?php $terms = apply_filters( ‘taxonomy-images-get-terms’, ”, array(‘taxonomy’ => ‘category’) ); $exclude = array(1,7); //add the category IDs to exlcude … Read more

Hide echo of no categories from get_object_taxonomies

I believe that what you want is show_option_none show_option_none (string) Set the text to show when no categories are listed. Defaults to “No categories”. http://codex.wordpress.org/Template_Tags/wp_list_categories#Parameters Proof of concept: $args = array(‘include’=>123,’show_option_none’=> ”); wp_list_categories( $args );

Order terms by count – missing terms

By default hide_empty is true for get_terms. So i guess you must be missing terms which do not have posts. Try this, <?php $terms = get_terms(“autorzy”, array(‘orderby’ => ‘count’, ‘order’ => ‘DESC’,’hide_empty’=>0 )); $count = count($terms); if ( $count > 0 ){ echo “<div>”; foreach ( $terms as $term ) { ?> <?php echo $term->name; … Read more