Skip to content

Create default pages and menus for a WordPress (WP) theme when WP is first loaded. The functions use WP functions and "wpdb class" to create new menus and pages. Functions are fired by "init hook".

Notifications You must be signed in to change notification settings

tomm-tomm/wp-init-pages-and-menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

This file contains five functions which creates default pages and menus for a WordPress theme when WordPress (WP) is first loaded. The functions uses WP functions and "wpdb class" to create new menus and pages. Functions are fired by "init hook".

Step 1: Creating new pages is handled by insert_default_pages() function. The function deletes all existing pages in WordPress (WP) and then creates new pages according to the defined list. The pages will be assigned an order so that they are clearly displayed in the list in the WP administration interface according to the appropriate hierarchy. The function sets the page called Home as the front page. Finally, it creates a WP option that ensures that pages are not deleted and created again on subsequent WP launches.

Step 2: The creation of new menus is handled by other 4 functions. The function register_and_creates_menu() registers the navigation according to the list of menus. Function create_menus(), generate_site_nav_menu() and generate_menu_item() then creates the items for each menu. Items are pages created in the first step. The requested pages must be listed in the create_menus() function. Finally, a WP option will be created to ensure that the menus are not registered and created again on subsequent WP launches.

About

Create default pages and menus for a WordPress (WP) theme when WP is first loaded. The functions use WP functions and "wpdb class" to create new menus and pages. Functions are fired by "init hook".

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages