Skip to content

Instantly share code, notes, and snippets.

@getdave
Created February 12, 2026 13:00
Show Gist options
  • Select an option

  • Save getdave/3b5474b67c889bb36c28ab9eee13d4fc to your computer and use it in GitHub Desktop.

Select an option

Save getdave/3b5474b67c889bb36c28ab9eee13d4fc to your computer and use it in GitHub Desktop.
Playground blueprint: Nav overlays, PHP-created pages matching menu
{
"$schema": "https://playground.wordpress.net/blueprint-schema.json",
"meta": {
"title": "Navigation Block with Hash Links & Customizable Overlays",
"description": "Testing Navigation Block with Hash Links. Uses Gutenberg branch with navigation overlays enabled by default.",
"author": "automattic"
},
"landingPage": "/wp-admin/site-editor.php?p=%2Fwp_template_part%2Ftwentytwentyfive%2F%2Fheader&canvas=edit&focusMode=true",
"preferredVersions": {
"php": "latest",
"wp": "latest"
},
"features": {
"networking": true
},
"login": true,
"steps": [
{
"step": "writeFile",
"path": "/wordpress/wp-content/mu-plugins/rewrite.php",
"data": "<?php /* Use pretty permalinks */ add_action( 'after_setup_theme', function() { global $wp_rewrite; $wp_rewrite->set_permalink_structure('/%postname%/'); $wp_rewrite->flush_rules(); } );"
},
{
"step": "runPHP",
"code": "<?php\nrequire '/wordpress/wp-load.php';\n\n$pages = array(\n array('title' => 'Home', 'slug' => 'home', 'parent' => 0),\n array('title' => 'About', 'slug' => 'about', 'parent' => 0),\n array('title' => 'Projects', 'slug' => 'projects', 'parent' => 0),\n array('title' => 'Contact', 'slug' => 'contact', 'parent' => 0)\n);\n\n$page_ids = array();\nforeach ($pages as $p) {\n $id = wp_insert_post(array(\n 'post_type' => 'page',\n 'post_title' => $p['title'],\n 'post_name' => $p['slug'],\n 'post_status' => 'publish',\n 'post_parent' => $p['parent'],\n 'post_content' => ''\n ));\n if ($id) $page_ids[$p['slug']] = $id;\n}\n\n$projects_id = isset($page_ids['projects']) ? $page_ids['projects'] : 0;\nfor ($i = 1; $i <= 5; $i++) {\n wp_insert_post(array(\n 'post_type' => 'page',\n 'post_title' => \"Project $i\",\n 'post_name' => \"project-$i\",\n 'post_status' => 'publish',\n 'post_parent' => $projects_id,\n 'post_content' => ''\n ));\n}\n\nupdate_option('show_on_front', 'page');\nupdate_option('page_on_front', isset($page_ids['home']) ? $page_ids['home'] : 0);\n\n$post_content = '<!-- wp:navigation-link {\"label\":\"Home\",\"url\":\"/\",\"kind\":\"custom\"} /--><!-- wp:navigation-link {\"label\":\"About\",\"url\":\"/about\",\"kind\":\"custom\"} /--><!-- wp:navigation-submenu {\"label\":\"Projects\",\"url\":\"/projects\",\"kind\":\"custom\"} --><!-- wp:navigation-link {\"label\":\"Project 1\",\"url\":\"/projects/project-1\",\"kind\":\"custom\"} /--><!-- wp:navigation-link {\"label\":\"Project 2\",\"url\":\"/projects/project-2\",\"kind\":\"custom\"} /--><!-- wp:navigation-link {\"label\":\"Project 3\",\"url\":\"/projects/project-3\",\"kind\":\"custom\"} /--><!-- wp:navigation-link {\"label\":\"Project 4\",\"url\":\"/projects/project-4\",\"kind\":\"custom\"} /--><!-- wp:navigation-link {\"label\":\"Project 5\",\"url\":\"/projects/project-5\",\"kind\":\"custom\"} /--><!-- /wp:navigation-submenu --><!-- wp:navigation-link {\"label\":\"Contact\",\"url\":\"/contact\",\"kind\":\"custom\"} /-->';\n\nwp_insert_post(array(\n 'post_type' => 'wp_navigation',\n 'post_title' => 'Test Navigation Menu',\n 'post_status' => 'publish',\n 'post_content' => $post_content\n));\n"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment