How can show the only child categories using shortcode
-
Hello,
I am facing issue while fetching all child categories in shortcode
i want to show only child categories in one box when we click on parent category which is located on another box.here is my codefunction catchild_shortcode($taxonomy_name, $termId, $args = array()) { $args = array( 'orderby' => 'name', 'order' => 'ASC', 'parent' => 0 ); $categories = get_categories($args); $output .= '<ul class="childcat_popup">'; foreach($categories as $category) { if ($category){ $output .= '<li><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>'; } } $output .= '</li>'; $output .= '</ul>'; return $output; } // register shortcode add_shortcode('cat-child', 'catchild_shortcode');
If anyone having idea about it.please let me know.
thanks in advance!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How can show the only child categories using shortcode’ is closed to new replies.