Changing stylesheet depending on custom taxonomy terms

Like Justin Tadlock says in your referenced article, the body_class() provides the ability to add classes dependant on the type of term. Given that you indicate your php knowledge is still growing; this maybe the best solution. The codex provides a list of classes on a body_class enabled: http://codex.wordpress.org/Function_Reference/body_class If that isn’t sufficient; wordpress has … Read more

Get Current Custom Taxonomy ID by Post ID

(Probably better to use get_the_terms). $terms = wp_get_object_terms( $pid, ‘custom_category’, array(‘fields’=>’ids’)); Get an array of term ids (will always been array, even if it is an array of one): $ids = wp_list_pluck( $terms, ‘term_id’ ); If you just want one id… then ‘pop’ out the last id: $id = array_pop($ids); See also PHP docs on … Read more

get_term_children doesn’t return an array of children terms

At first, try passing the Taxonomy as a string: $children = get_term_children($term->term_id, ‘locations’); The function get_category_children produces a string as return, so you can just echo it. the function get_term_children, however, returns an array. To see the contents of the array, try print_r( $children ); instead of echo. The last thing to keep in mind … Read more

How can i list the categories of a post type, the taxonomy

This should get you started function my_cpt_cats() { $parent = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); $args = array( ‘type’ => ‘post’, ‘child_of’ => $parent->term_id, ‘parent’ => ”, ‘orderby’ => ‘slug’, ‘order’ => ‘DESC’, ‘hide_empty’ => 1, ‘hierarchical’ => 1, ‘exclude’ => ”, ‘include’ => ”, ‘number’ => ”, ‘taxonomy’ => ‘YOUR_TAXONOMY’, … Read more

Custom Field as Custom Taxonomy?

Without knowing exactly how your input form looks, I can only give you the following as a suggestion. Basically you verify that you want/have permission to save the data and then take the meta’s input and set it as a term in your taxonomy via wp_set_object_terms(). You’ll want to fire this every time a post … Read more

Showing custom taxonomy column in taxonomy category listings immediately after create category

What is happening is that: the page /wp-admin/edit-tags.php uses $_GET[‘taxonomy’] and /wp-admin/admin-ajax.php, fired when we create a new term, uses $_POST[‘taxonomy’] To solve it, use $_REQUEST in manage_my_category_columns(). It will cover both GET and POST: if ( !isset( $_REQUEST[‘taxonomy’]) || $_REQUEST[‘taxonomy’] != ‘products’ ) Related Q&A: WP List Table custom quick edit box – post … Read more

wp_insert_post not updating custom taxonomy selected if logged in as a subscriber

It’s because within wp_insert_post current user capabilities are checked before adding the terms: if ( current_user_can($taxonomy_obj->cap->assign_terms) ) wp_set_post_terms( $post_ID, $tags, $taxonomy ); to get around this, use wp_set_object_terms instead after wp_insert_post to add the terms: $new_post = array( ‘post_title’ => $postTitle, ‘post_content’ => $post, ‘post_status’ => ‘publish’, ‘post_date’ => date(‘Y-m-d H:i:s’), ‘post_author’ => $user_ID, ‘post_type’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)