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

Show related posts on single.php, grouped by taxonomy terms, with Advanced Custom Field post object selected

I’d recommend creating 3 separate [‘associated_items’] fields instead of 1. For Example: [‘associated_articles’] & “Filter for taxonomy term: Articles” [‘associated_presentations’] & “Filter for taxonomy term: Presentations” [‘associated_news’] & “Filter for taxonomy term: News” Note: Filtering for the taxonomy term, limits the related posts available to choose from as well, which results in a better user … Read more