How to make dynamic sub-pages as sub-navigation in a page in wordpress

WordPress
How to make dynamic sub-pages as sub-navigation in a page in wordpress

Last day, we were working on a website in WordPress. The website contains few subpages and the client want the navigation for the subpages on the right side of the Web page. We had faced some difficulties to get it done. Finally, after a deep research we got a perfect solution for this and that has been mentioned below.

Paste this code where you want your subpage navigation and add subpages created under the main page.

 

< ?php

$children = wp_list_pages('depth=-1&title_li=&child_of=' . $post->ID . '&echo=0');

echo '
    '; if ($children) { echo $children; } elseif ($post->post_parent) { echo $children = wp_list_pages('depth=-1&title_li=&child_of=' . $post->post_parent . '&echo=0'); //echo '
  • ' . get_the_title() . '
  • '; } echo '
    '; ?>

Leave a Reply

Your email address will not be published. Required fields are marked *

4 × 2 =

2hats Logic HelpBot