get_term_children returns WP_Error for custom taxonomy

Since get_term_link() will return a WP_Error object if the term does not exist, you could try: $termchildren = get_term_children( $taxID, $taxType ); echo ‘<ul>’; foreach ( $termchildren as $child ) { $term = get_term_by( ‘id’, $child, $taxType ); $term_link = get_term_link( $term->name, $taxType ); if( ! is_wp_error( $term_link ) ) echo ‘<li><a href=”‘ . $term_link … Read more

Show only first children level of current category?

You are using get_categories() function and this function have not ‘depth‘ argument. Also php is not supporting $cat-id variable. it would be $cat_id. So try this kind of code: $cat_id = get_query_var(‘cat’); $args=array( ‘parent’ => $cat_id, ‘hide_empty’ => 0, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’ );

Get ID of child from child slug, while knowing parent ID

You should use the pagename parameter for WP_Query along with post_parent. Limit your query to one post using posts_per_page. $parent_id = get_the_ID(); $args = array( ‘post_type’ => ‘page’ ‘pagename’ => ‘page-2’, ‘post_parent’ => $parent_id, ‘posts_per_page’ => 1 ); $posts = get_posts( $args ); $child = isset( $posts[0] ) ? $posts[0] : false; if( $child ){ … Read more

Multiple Conditions for Child Page Title

Based on the comment exchange, here’s what I think you’re after: <h1><?php echo get_the_title( $post->post_parent ? $post->post_parent : $post->ID ) ?></h1> <?php if ( $list = wp_list_pages( “echo=0&child_of=$post->ID” ) ) : ?> <h2>Select a sub-page</h2> <ul> <?php echo $list ?> </ul> <?php elseif ( $post->parent ) : ?> <h2><?php the_title() ?></h2> <?php endif ?>

List the 5 most recent child pages

Assuming you know (or know how to get) the $id (as an integer) of the parent post, use the post_parent parameter: $albums = new WP_Query(array( ‘post_type’ => ‘gallery’, ‘posts_per_page’ => 6, ‘post_parent’ => $id )); Edit Based on this comment: I don’t know the parent post. I want to list the most recent child pages … Read more

How to create drop down for child categories of current taxonomy being viewed?

Ok well without any help from here……. I was able to figure out how to change the option and select values of wp_dropdown_categories to display the child terms of the current taxonomy being viewed- First I placed this code into my functions file, which creates a walker class – class SH_Walker_TaxonomyDropdown extends Walker_CategoryDropdown{ function start_el(&$output, … Read more

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