0

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>

migrated from stackoverflow.com Nov 12 '12 at 14:09

This question came from our site for professional and enthusiast programmers.

0

Figured it out, there is no such thing as "dataslug", changed it to "data-slug" and it worked perfectly. Really stupid mistake.

I guess most people don't use the tag, but if anyone wants to know you could easily replace it with a and give it a 'scrollto' class using the scrollto jquery plugin. Just a thought.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.