Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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>
share|improve this question
add comment

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

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

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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