Articles of get categories

Function/Class to list categories with checkboxes

I want a list like in the pictue; witch is here – Posts->New->Select Categories At the moment i have this echo ‘<select name=”pn-cats[]” size=”8″ style=”width: 100%” multiple>’; $args = array( ‘type’ => ‘post’, ‘child_of’ => 0, ‘parent’ => ”, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘hide_empty’ => 0, ‘hierarchical’ => 1, ‘exclude’ => ”, ‘include’ […]

Getting the first parent of a hierarchical term

How get avô this hierarqui category: avô -mae –filho It always give me the last child : <?php $product_cats = wp_get_post_terms( get_the_ID(), ‘product_cat’ ); $single_cat = array_shift( $product_cats ); echo $single_cat->slug; ?> Result: filho Must obtain the category avô UPDATE: $product_cats return: Array ( [0] => stdClass Object ( [term_id] => 16 [name] => Display […]

Latest updated categories list query, exclude one from displaying

I have this query: $cat_array = array(); $args=array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘exclude’ => ‘187’, ‘posts_per_page’ => 19, ‘caller_get_posts’=> 1 ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); $cat_args=array(‘orderby’ => ‘none’); $cats = wp_get_post_terms( $post->ID , ‘category’, $cat_args); foreach($cats as $cat) { $cat_array[$cat->term_id] = $cat->term_id; […]

Get child categories of custom taxonomy category?

I am using custom post type : portfolio and have taxonomy for that portfolio_category. I need to get sub categories for a particular category using the above custom taxonomy. In short, How can I get the child categories for taxonomy=portfolio_category&tag_ID=80&post_type=portfolio?

Get the child category ID of current category

I am trying to get the category ID of the child (no grand children) of the current category. Using below method: $category = get_category(get_query_var( ‘cat’ )); // get category ID $catid = $category->cat_ID; I can get the current category ID. However, using this in WP_Query result in displaying the posts that are published in Parent, […]

WP Dropdown Categories, display subcategories but not grandchildren categories?

So my main goal is to create 3 drop-down category options to run a search. It’s for a car website, so I have 3 parents, “Make”, “Model”, and “Year” At the moment I have the following code <?php $args = array(‘show_option_none’ => ‘Make’, child_of => 5,hide_empty => ‘0’,exclude => ‘0’); ?> <b>Make </b><?php wp_dropdown_categories($args); ?> […]

Group child category IDs based on their parent category

I have IDs for my child categories, 11,14,21,35,38,39, where these all are various child categories from their main category: Parent category 1 has: 11,14 Parent category 2 has: 21 Parent category 3 has: 35,38,39 How can I group my child IDs as per their parent category, like below? array( 1 => array ( 11,14 ), […]

How to display taxonomy terms the way they are hierarchical

Reading Kaiser’s query and Scribu’s answer I’m now in an ocean of no shore. I made a custom taxonomy, where I want to show the terms as per their hierarchy, like below: Level 0 — Level 1 — Level 2 —- Level 3 — Level 2 —- Level 3 —- Level 3 — Level 1 […]

Loop categories by recent post

Im looking for a way to loop through categories and then display the recent posts for each one in a container but I need a way to sort the categories by which ones have the most recent posts So if Category C has a more recent post then it’ll appear first before Category A $args […]

Difference between wp_list_categories and get_categories

Whats the difference between the wp_list_categories and get_categories? WordPress codex says use get_categories if needs a function that does not format the results what format is this referring to? Will it affect the performance if I use the other one? And if i want to display all the hierarchical custom taxonomy links on a page, […]