If you want to display the sub page list link in the WordPress parent page, you can use the following code.
Add the following code to the current topic functions.php:
function wpb_list_child_pages() { global $post; if ( is_page() && $post->post_parent ) $childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->post_parent . '&echo=0' ); else $childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0' ); if ( $childpages ) { $string = '<ul>' . $ childpages . '</ul>'; } return $string; } add_shortcode('wpb_childpages', 'wpb_list_child_pages');
After that, you can use short codes:
[wpb_childpages]
Add to the text widget.
The default text widget does not support short codes. You can set:
add_filter('widget_text', 'do_shortcode');
Add to the current topic functions.php to enable the text widget to support short code.
You can also add the following code to the appropriate location of the theme page template:
<? php wpb_list_child_pages(); ?>
For example, if you create a new page template and add code, you can only select the new page template when using this function.
Original text: How to Use Shortcodes in your WordPress Sidebar Widgets
Most of the articles on this site are original and used for personal learning records, which may be helpful to you, for reference only!