. The rest of the code described in this section will be moved here. Function conversation list _ subpage (){
\/*Here’s the code*\/
}This new feature performs three actions: Prepare the search parameters to find sub pages using the previously discovered page ID. Perform a search to ensure that subpages exist. If there are sub pages, the list is returned. From the code format, it is shown as follows: The
\/\/Step 1: use the top-level page ID to set the search parameters
$parent_id = torque_check_for_parent_page();
$args= array(
‘child\u of’= > $parent\u ID,
\
\
);
\/\/Step 2: search sub page
$subpages = get_pages ($args);
\/\/Step 3: if there are sub pages, return to the list
If ($subpages){
\/\/Start list of top pages
? >
Male
Male
Male \
Male
Male
Male
The last step is to work in PHP functions. This time it will work inside the PHP class. Set up the shell as follows: Class torque\u automatic\u section\menu extension wp\u widget{
\/*Here’s the code*\/
}PHP classes group functions that work together in a package so that you can later manage complex functions through simple code calls. This new part class handles four functions. The
Initialize components and default options. Build a user interface (UI) in the word press dashboard to place it in the constructs area. Save changes made using the UI on the word press dashboard. Generate the output displayed at the front of the site. Let’s look at these features step by step. Add each of these items to the class rapper you create later. First, you must initialize the component and register the default options in word press. Function _\u configuration (){
$widget_options= array(
\
\
);
Parent:\u construct (\
}Next, create a small HTML form for the word press dashboard. Then, the code snippet replaced by the drag and drop component in the shape > component page and the customization program is output. The
Function type ($instance){
? >
Male
Male get\u field\u ID (‘title’);? > \
Male get\u field\u name (‘title’);? > \
Male
Male
Male
Male
Male
Male
Male then move to shape > part. Navigate to the new partial menu component, drag it to the sidebar area, and save your changes. Finally, view one of the subpages of the WordPress website. If all goes well, all other relevant pages in the same section should be neatly displayed on the sidebar! Conclusion some menus are very helpful for users running large or complex websites. Registering the automatic part menu to be used in the sidebar can easily be made available to visitors, and the deviation rate can be reduced by improving UX. This article describes the five steps to create a custom component plug-in that generates this navigation\/ Set an empty plug-in folder under WP content. Browse the parent page and return its ID. Use the partial menu to detect and list sub pages. Register some menu components. Use WordPress manager to add parts to the sidebar. Auto part menu
Any questions about build? Please let us know in the comments section below! Photo credit: Julien lux.