https://github.com/tomm-tomm/wp-init-pages-and-menu
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".
https://github.com/tomm-tomm/wp-init-pages-and-menu
mysql php wordpress wp-theme wp-theme-starter wpdb
Last synced: about 2 months ago
JSON representation
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".
- Host: GitHub
- URL: https://github.com/tomm-tomm/wp-init-pages-and-menu
- Owner: tomm-tomm
- Created: 2024-11-18T11:21:42.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-11-19T10:05:29.000Z (6 months ago)
- Last Synced: 2025-01-27T10:43:38.767Z (4 months ago)
- Topics: mysql, php, wordpress, wp-theme, wp-theme-starter, wpdb
- Language: PHP
- Homepage:
- Size: 3.91 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.MD
Awesome Lists containing this project
README
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.