Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Problem with One Page WordPress Site

I just watched the workshop 'One Page WordPress Site' and it is fantastic, but I have one question about it:

Is it possible to change the order of the pages on the one page site manually?

So the user of the WordPress site can change the order without coding?

Sincerely, Joren

2 Answers

You have to tweak the code from the workshop a little but this is possible. In the workshop video, Zac uses these arguments for the query:

<?php
$args = array(
    'post_type' => 'page',
    'order' => 'ASC'
);
?>

You can change it to order by menu_order. This will allow you to order by the Order field in the Edit Page Attributes box. To do this, change your arguments to:

<?php
$args = array(
    'post_type' => 'page',
    'order' => 'ASC',
    'orderby' => 'menu_order'
);
?>

For more info on ordering, see the Order & Orderby section of the WP_Query page in the WordPress Codex.

I put the code in my functions.php, but nothing has changed.

How can the user change the order of this pages now?

When you edit the page, edit the order in the Page Attributes Box:

order WordPress pages