Adding a second custom taxonomy to a custom post type (both shown in its table)?

I use the following in my filter hook manage_edit-<post-type>_columns add_filter( ‘manage_edit-visitor_columns’, array( &$this, ‘_wp_filter_visitor_columns’ ) ); public function _wp_filter_visitor_columns( $columns ) { $columns = array( ‘cb’ => ‘<input type=”checkbox” />’, ‘title’ => ‘Name’, ‘type’ => ‘Type’, //’state’ => ‘Current State’, ‘id’ => ‘Visitor ID’, ‘acct’ => ‘Using Account’, ); return $columns; } And to filter … Read more

Permalink Problems

Sorry guys, this is becoming a habit, but I found a solution, as follows: set rewrite to false in taxonomy registration: register_taxonomy(‘property_type’,array(‘sbproperty’), array( ‘hierarchical’ => true, ‘labels’ => $labels, ‘show_ui’ => true, ‘query_var’ => true, ‘rewrite’ => false )); And create my own rule add_filter(‘rewrite_rules_array’,’wp_insertMyRewriteRules’); add_filter(‘init’,’flushRules’); function flushRules(){ global $wp_rewrite; $wp_rewrite->flush_rules(); } function wp_insertMyRewriteRules($rules) { … Read more

Why doesnt this query work? (Custom Taxonomy)

you mixed the query with the register function, try this: function taxonomy_init() { // create a new taxonomy register_taxonomy( ‘country’, ‘post’, array( ‘label’ => __(‘Countries (Labels)’), ‘rewrite’ => array(‘slug’ => ‘location’) ) ); } add_action( ‘init’, ‘taxonomy_init’ ); the in your query use $my_query = array( ‘posts_per_page’ => 10, ‘tax_query’ => array( array( ‘taxonomy’ => … Read more

Proper use of wp_get_object_terms

To fetch the archive url for that taxonomy term, use something like this (I’m using your naming conventions above, and assuming that $theZielgruppe is a term object. $url = get_term_link( $theZielgruppe, ‘ge_zielgruppe_taxonomy’ ); To get the name, just use $theZielgruppe->name Is that what you’re looking for? EDIT The link above would then look like this: … Read more

saving meta/custom field to tag

you can use wp_insert_term() to create the tag and then wp_set_object_terms() to set it as the custom post tag: //get the tag $tag = $_POST[‘ad_Tags’]; //create the tag $term_id= wp_insert_term( $tag, // the term ‘post_tag’, // the taxonomy array(‘description’=> ‘term description’,’slug’ => ‘term-slug’) ); //set the tag wp_set_object_terms( $post_id, $term_id, ‘post_tag’ );

Removing “trashed” posts from post count in custom taxonomy terms?

This is a known, reported WordPress bug. There are some workarounds, such as this one: add_action( ‘edited_term_taxonomy’,’wpse26548_edited_term_taxonomy’, 10, 2 ); function wpse26548_edited_term_taxonomy($term,$taxonomy) { global $wpdb,$post; //in quick edit mode, $post is an array() //in full edit mode $post is an object if ( is_array( $post )) $posttype=$post[‘post_type’]; else $posttype=$post->post_type; if ($posttype) { $DB_prefix=$wpdb->get_blog_prefix(BLOG_ID_CURRENT_SITE); $sql = … Read more