0
votes

I need to list all the parent and child category dynamically in wordpress menu as well as when clicks on each it should go to new page that shud list the posts belongs to those categories ,please give me an idea how to do this

For Reference .

www.inagercoil.com/futar

1

1 Answers

0
votes

use this function

<?php 
    $args = array(
    'show_option_all'    => '',
    'orderby'            => 'name',
    'order'              => 'ASC',
    'style'              => 'list',
    'show_count'         => 0,
    'hide_empty'         => 1,
    'use_desc_for_title' => 1,
    'child_of'           => 0,
    'feed'               => '',
    'feed_type'          => '',
    'feed_image'         => '',
    'exclude'            => '',
    'exclude_tree'       => '',
    'include'            => '',
    'hierarchical'       => 1,
    'title_li'           => __( 'Categories' ),
    'show_option_none'   => __( '' ),
    'number'             => null,
    'echo'               => 1,
    'depth'              => 0,
    'current_category'   => 0,
    'pad_counts'         => 0,
    'taxonomy'           => 'category',
    'walker'             => null
    );
    wp_list_categories( $args ); 
?>

and in this function

hierarchical 
(boolean) Display sub-categories as inner list items (below the parent list item) or inline. The default is true (display sub-categories below the parent list item). Valid values:
1 (True) - Default
0 (False)

for each category click new page visit with belonging post

Displays a list of Categories as links. When a Category link is clicked, all the posts in that Category will display on a Category Page using the appropriate Category Template dictated by the Template Hierarchy rules.

For More info

https://codex.wordpress.org/Template_Tags/wp_list_categories

visit this link..