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; } }
What is the job of $section_name? Also you must get an return; you if statement kill the default return. It is important, if your if statement fails. maybe this works, but not tested, write from scratch. add_filter( ‘body_class’, ‘section_id_class’ ); // add classes to body based on custom taxonomy (‘sections’) // examples: section-about-us, section-start, section-nyc … Read more
My gut instinct would be to roll my own AJAX callback. You obviously know the post ID (since you have it on the front end) and the names of the fields, just post that back to WP using AJAX and programmatically set the values there. An untested example (props to Kailey Lampert): // Add checkboxes … 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
Terms should work like categories (which basically they are but with with different names). They are attached to posts but not dependent upon them. If you delete a post the term stays, like with categories. Custom post meta is dependent upon its post and will be deleted when the post is permanently deleted. It isn’t … Read more
Ok well without any help from here……. I was able to figure out how to change the option and select values of wp_dropdown_categories to display the child terms of the current taxonomy being viewed- First I placed this code into my functions file, which creates a walker class – class SH_Walker_TaxonomyDropdown extends Walker_CategoryDropdown{ function start_el(&$output, … Read more
First you really shouldn’t use query_posts for that use get_posts or WP_Query and second tax_query accept an array of arrays from the codex: tax_query takes an array of tax query arguments arrays (it takes an array of arrays) so: $terms=get_terms(‘tax_name’); $request=array(); foreach((array)$terms as $t) $request[]=$t->slug; $tax_q = new WP_Query( array( ‘post_type’ => ‘post’, ‘posts_per_page’ => … Read more
function get_issues() { $output = array(); $hlterms = get_terms(‘issue’, array(‘orderby’ => ‘id’, ‘order’ => ‘DESC’,’hide_empty’ => false)); foreach($hlterms as $term){ array_push($output, $term->term_id); } return $output; } This would return you term id as per the recent and then in your second function start iterating to get the posts for latest issue. function get_posts_for_current_issue() { $total_issues … Read more
It depends of what you are trying to do exactly. But if you want the same functionality of the question you linked, you can use the same function but passing your custom taxonomy to the function. Here all the arguments you can pass to wp_list_categories() and is defulat values: <?php $args = array( ‘show_option_all’ => … Read more