Getting one specific value from get_children array

If you want to query by a post author , you can try the author input argument: $sub_orders = get_children( array( ‘author’ => $seller_id, ‘post_parent’ => $reservation->transaction_id, ‘post_type’ => ‘shop_order’, ‘post_status’ => array( ‘wc-pending’, ‘wc-completed’, ‘wc-processing’, ‘wc-on-hold’ ) ) ); Note that get_children() calls get_posts(), that is again a wrapper for WP_Query, so you can … Read more

Listing Child Pages in Random order

The sort_column parameter of wp_list_pages() does allow items to be returned in random order using the rand option. sort_column (string) Comma-separated list of column names to sort the pages by. Accepts ‘post_author’, ‘post_date’, ‘post_title’, ‘post_name’, ‘post_modified’, ‘post_modified_gmt’, ‘menu_order’, ‘post_parent’, ‘ID’, ‘rand’, or ‘comment_count’. Default ‘post_title’. add_shortcode( ‘wpb_childpages’, ‘wpb_list_child_pages’ ); function wpb_list_child_pages() { global $post; if … Read more

Getting child category id (help with improving my code)

Starting from your parent category slug you can use the following code to get the child categories: $parent = get_category_by_slug(‘winners-2018’); $catz = get_categories( array( ‘parent’ => $parent->cat_ID ) ); foreach ($catz as $cat_archive) { // No need for get_category(); because get_categories() already returns category objects … }

Attempting to get number of grandchildren of page in WP_Query loop

Found a solution! $inner_query = new WP_Query(array( ‘post_parent’ => $parentid, ‘post_type’ => ‘location’, ‘posts_per_page’ => -1 ) ); $countchildren = $inner_query->post_count; $counterz = 0; if ( $inner_query->have_posts() ) { while ( $inner_query->have_posts() ) { $inner_query->the_post(); $posterid = get_the_ID(); $inner_inner_query = new WP_Query(array( ‘post_parent’ => $posterid, ‘post_type’ => ‘location’, ‘posts_per_page’ => -1 ) ); $counterz = … Read more

check if page have children, but not attachment

You should specify the post_type for the get_children() function, which can be one of attachment, page, revision or any and considered to be any by default: $children = get_children( array( ‘post_parent’ => get_the_ID(), ‘post_type’ => ‘page’ ) );

Get children of taxonomies

not actually sure what you are trying to achieve with the code. I would write something like this to get the child terms $terms = get_terms([ ‘taxonomy’ => array(‘Movies, Musics, Books, Games’), ‘parent’ => 0, ‘hide_empty’ => false, ]); if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) { foreach ($terms as … Read more

Show subChild categories

only getting deep in the code, but this should give the categories associated with the product $sub_child = $product->get_categories(); foreach($sub_child as $a){ echo $a; } if this gives the sub-child, child and parents, then must be built some kind of filter to show only the sub-child. to the sub-districts I imagine something like: $district = … Read more