How do I get the slug of a custom taxonomy category of a post?
This shouldn’t be too hard! $my_terms = get_the_terms( $post->ID, ‘portfolio’ ); if( $my_terms && !is_wp_error( $my_terms ) ) { foreach( $my_terms as $term ) { echo $term->slug; } }
This shouldn’t be too hard! $my_terms = get_the_terms( $post->ID, ‘portfolio’ ); if( $my_terms && !is_wp_error( $my_terms ) ) { foreach( $my_terms as $term ) { echo $term->slug; } }
media handle sideload returns an attachment ID, and attachments are normal posts with the post type ‘attachment’. All the same things apply, featured images parents taxonomies post meta etc albeit with a few attachment oriented functions like wp_get_attachment_image So use wp_set_object_terms as you normally would, e.g.: $id = media_handle_sideload(…. if(!is_wp_error($id)){ wp_set_object_terms( $id, array(terms…), $taxonomy, $append … Read more
You can insert an associative array into the post_meta_field. Here is a quick little function to grab the data afterward (did not test): function grab_task_name_array($post_id) { $new_array = array(); $array = get_post_meta($post_id,’_task-name’); //do not put true as third parameter (this would return string and not array) foreach($array[0] as $key => $value) $new_array[$key] = $value; return … Read more
There are plenty of functions for grabbing the data you need, a quick look at the Codex function reference reveals many useful functions you can use to build this. Use get_term_link to get the link to that terms archive, and wp_get_object_terms to get the terms of an object/post. To get all terms in a taxonomy … Read more
The filter you are looking for is term_links-$taxonomy, where $taxonomy is the taxonomy name. This will filter the $term_links links array before outputting by the_terms(): add_filter(‘term_links-cities’, ‘ad_filter_links’); function ad_filter_links($term_links) { foreach ($term_links as $term_link) { $term_link = str_replace(‘<a ‘, ‘<a class=”fancybox”‘, $term_link); } return $term_links; }
Tax Query Limits A Taxonomy Query in WordPress supports the following three arguments for the operator parameter: IN, NOT IN and AND. So it basically can’t do what you’re trying to do. Not even with advanced (tax_query) Queries. Meta Query and possibilities You’ll want to move your concept a bit and work with post meta … Read more
get_categories() fetches taxonomies of type ‘categories’ particularly http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/category.php#L0, to fetch custom taxonomy you should use get_terms() instead, here http://codex.wordpress.org/Function_Reference/get_terms $terms = get_terms( ‘partner-cat’, ‘orderby=count&hide_empty=0’ ); $count = count($terms); if ( $count > 0 ){ echo “<ul>”; foreach ( $terms as $term ) { echo “<li>” . $term->name . “</li>”; } echo “</ul>”; } Make sure … Read more
Edit If this is your goal: I want to use the WordPress gallery to show all pictures of one category in a gallery (on a fixed page), which I do not have to update all the time by inserting the pictures manually. Then the easiest way to accomplish it is via custom page template. Create … Read more
Register your taxonomies with ‘show_ui’ => false, and then add a single meta box to manage them. function create_book_tax() { register_taxonomy( ‘genre’, ‘book’, array( ‘label’ => __( ‘Genre’ ), ‘rewrite’ => array( ‘slug’ => ‘genre’ ), ‘hierarchical’ => true, ‘show_ui’ => false, ) ); } Or unhook the boxes from the side panel and put … Read more
It sounds like you are are using get_term() for a custom taxonomy. If you’re using get_term() inside functions.php and outside of a hooked function, that code is going to be run immediately when functions.php is loaded. Your custom taxonomy will not have been registered at this point, because that happens on the init hook. Your … Read more