I'm trying to create a single page wordpress theme. Whenever I add a new page, I want a new to be added to my Single page theme. I'm currently using this code:
$pages = get_pages( array ( 'sort_order' => 'asc', 'sort_column' => 'menu_order', 'depth' => 1));
foreach ( $pages as $page ) {
$page_section = str_replace( " ", "", strtolower( $page->post_name ) );
echo '<section id="' . $page_section . '" dataslug="' . $page_section . '" ></section>';
}
?>
What I want is for it to create a new with an ID and Dataslug that match the page name (which is also the label on the link in the Menu). For example, say I insert a page called about, The menu item will read "about" and this code will be added to the page
<section id="about" dataslug="about"></section>