get term slug from current posts’s custom taxonomy

This gets the terms: $terms = get_the_terms( get_the_ID(), ‘nieuwssoort’); Then you check the result: $terms_ids = [];//you can set a default id here if(false !== $terms && !is_wp_error($terms)){ foreach($terms as $term){ $terms_ids[] = $term->term_id; } } We check the result just in case. Now, we have the values, let get them into the arguments: $args … Read more

Taxonomy count per Post type

I needed to get the number of post per type per term so i created this small function: function get_term_post_count_by_type($term,$taxonomy,$type){ $args = array( ‘fields’ =>’ids’, //we don’t really need all post data so just id wil do fine. ‘posts_per_page’ => -1, //-1 to get all post ‘post_type’ => $type, ‘tax_query’ => array( array( ‘taxonomy’ => … Read more

Display taxonomy term slugs

You code is completely wrong. array_shift should not be used array_shift() shifts the first value of the array off and returns it, shortening the array by one element and moving everything down. All numerical array keys will be modified to start counting from zero while literal keys won’t be touched. You should have a look … Read more

Display Custom Column in CPT Taxonomy

The final working hooks that I was able to work out are: // adding an extra column to the event_cateogires page // to display the color function events_color_column($defaults) { $defaults[‘event_cat_color’] = ‘Event Category Color’; return $defaults; } function events_color_column_content($column_name, $post_ID) { echo ‘Event Color : #2432’; } add_filter(‘manage_edit-event_categories_columns’, ‘events_color_column’); add_action(‘manage_event_categories_custom_column’, ‘events_color_column_content’, 10, 2); Using the … Read more

List all posts from custom post type by taxonomy

You could try this way. Create a new page called say ‘All products’ and apply the following template to it. Here is the code for that should be used in your template, just above the while loop. $type=”products”; $args=array( ‘post_type’ => $type, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘caller_get_posts’=> 1 query_posts($args); A complete sample template … Read more

How to loop through 1 CPT with 2 Taxonomies

You probably want to use wp_get_post_terms(). If a product is always associated to only one category – which has no child if hierarchical – (what I understand from your example), adding below snippet within your while loop should do it (not tested). <? $cat = wp_get_post_terms( get_the_ID(), ‘department’ ); echo ‘<span>(‘ . $cat->name . ‘)</span>’; … Read more

WordPress taxonomy child image

You need to ask for the child term image field. You have only asked for the current page’s query object image, which may be blank depending on what the query object is. <?php $term_id = get_queried_object()->term_id; $taxonomy_name = get_query_var( ‘taxonomy’ ); $termchildren = get_term_children( $term_id, $taxonomy_name ); // Loop through each child taxonomy term foreach … Read more

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