WooCommerce – Display product child categories from specific parent

The woocommerce function get_categories() is declared in abstract-wc-product.php, because it is based on the wordpress function get_the_term_list() there is no way to get only a specific branch of a category. This absolutely isn’t the same as the wordpress function get_categories(), you can see that it is woocommerce specific by how it’s used $product->get_categories(). Besides the … Read more

get_children – wp_get_attachment_image

You could Limit the output to 1 like this but this is not a solution, only a workaround: $args = array(‘post_parent’ => get_the_ID(), ‘numberposts’ => 1, ‘order’ => ‘ASC’, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’ ); $images = get_children( $args ); if ($images) { foreach ($images as $image) { echo wp_get_attachment_image($image->ID, ‘full’); } } Have … Read more

How to order get_term_children output by alphabetic order

Per your comment (and hopefully an edit to the question) : I did it like so: foreach ( $termchildren as $child ) { $term = get_term_by( ‘id’, $child, $taxonomy_name, array( ‘orderby’ => ‘name’, ‘hide_empty’ => 0) ); Formatted: foreach ( $termchildren as $child ) { $term = get_term_by( ‘id’, $child, $taxonomy_name, array( ‘orderby’ => ‘name’, … Read more

Child terms from multiple parents?

We can filter the generated SQL query through the terms_clauses filter before the SQL query is executed. What we will be doing is to introduce a new parameter called wpse_parents which will accept an array of parent term ID’s to get children from. Note, this new parameter works exactly the same as the build-in parameter, … Read more

get_children() Not Working with orderby Parameter

Are you sure you need this specific function? Documentation (both Codex and inline) is verrry confusing. And it supposedly fetches things like attachments, which probably aren’t relevant for navigation… Try this: get_posts( array( ‘post_type’ => ‘page’, ‘post_parent’ => $parent->ID, ‘orderby’ => ‘menu_order’ ) );

get_term_children for immediate children only (not grandchildren)

Use the get_terms() function instead: $term_children = get_terms( ‘mytaxname’, array( ‘parent’ => get_queried_object_id(), ) ); if ( ! is_wp_error( $terms ) ) { foreach ( $term_children as $child ) { echo ‘ <div class=”product-archive”> <div class=”post-title”> <h3 class=”product-name”><a href=”‘ . get_term_link( $child ) . ‘”>’ . $child->name . ‘</a></h3> </div> </div> ‘; } } get_terms() … Read more

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