Problem retriving the post type category

get_terms retrieves all terms in a taxonomy, not terms added to a post. you want to use get_the_terms to retrieve terms assigned to a specific post. there are no additional arguments to filter the list of terms returned, you’ll have to manually check a term’s parent to only output terms that are a child of … Read more

view subcategories order by id

If you want to order by id you can replace $subcategories = get_terms( ‘category’ , ‘parent=”.get_query_var(“cat’) ); with $args=array( ‘parent’=>get_query_var(‘cat’), ‘orderby’ => ‘id’, ‘order’ => ‘ASC’, ); $subcategories = get_terms( ‘category’ , $args); You can read more about the available parameters in the Codex here: http://codex.wordpress.org/Function_Reference/get_term

Show single Child Category on Custom Post

You can use get_term_children function. For Example: <?php $termID = 10; $taxonomyName = “region”; $termchildren = get_term_children( $termID, $taxonomyName ); echo ‘<ul>’; foreach ($termchildren as $child) { $term = get_term_by( ‘id’, $child, $taxonomyName ); echo ‘<li><a href=”‘ . get_term_link( $term->name, $taxonomyName ) . ‘”>’ . $term->name . ‘</a></li>’; } echo ‘</ul>’; ?>

Order taxonomy terms wordpress

You’re not setting an order anywhere for get_terms, you’re setting it for the query of articles within each term. You need to pass arguments to get_terms if you want an order other than default, which is ASC. $tax = ‘news’; $tax_args = array( ‘order’ => ‘DESC’ ); $tax_terms = get_terms( $tax, $tax_args );

Retrieve Custom Taxonomies with Description and Slug

Here’s how you can output all the custom taxonomies in any template for examination: <pre> <?php $args = array( ‘public’ => true, ‘_builtin’ => false ); $taxes = get_taxonomies( $args, ‘objects’); foreach ($taxes as $key => $tax) { $terms = get_terms( $tax->name, array(‘hide_empty’ => false) ); // return empty ones too! foreach ($terms as $key … Read more

Show all terms in a custom taxonomy with all child terms wrapped in a ul

You can take a look at the WordPress function wp_list_categories(). If you want to display all the terms within a given custom taxonomy you can for example use: <?php $args = array( ‘taxonomy’ => ‘my_custom_taxonomy_slug’, ‘orderby’ => ‘name’, ‘hide_empty’ => 0, ‘title_li’ => ”, ‘hierarchical’ => 1, ‘walker’ => null, ); ?> <ul class=”menu”> <?php … Read more

Woocommerce getting top level category parent and make all sub categories have the same template and menu

WP native function get_queried_object() can help you to get an ID of a currently displayed term. WooCommerce then includes this handy function: woocommerce_get_term_top_most_parent() (originated here on WPSE btw,) that will get it’s top-level parent term. I haven’t tested the following code but it should provide a good starting point: if ( ‘wedgwood’ == woocommerce_get_term_top_most_parent( get_queried_object()->term_id … Read more

How to break up php code to avoid echo

You have an extra “}”, there must be two such braces for two for each loops. Also you need to have endif; statement at end after endwhile. Parsing error may be due to extra “}”. Please try below code and let us know if it works. <?php $custom_terms = get_terms(‘videoscategory’); $other_custom_terms = get_terms(‘product_category’); foreach ($custom_terms … Read more