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

Wordpress Custom Fields

how to add 'order attributes option' on Advanced Custom Fields

I'm confused, are you trying to add the page attribute's order option to Advanced Custom Fields, and If so, why are you trying to do that.

Hi andrew, i have made a custom post type on team members with 10 staff on them. Now i want a option where i can reorder the staffs member, Is that possible?

Yes, see my answer below.

2 Answers

So what you need to do is add a new custom field to your custom post type called something like "staff order". Then you will need to create a custom wp_query object to order the staff posts in "staff order".

<?php 
        $args = array(
            'post_type' => 'NAME_OF_CUSTOM_POST_TYPE',
            'orderby' => 'meta_value',
            'meta_key' => 'NAME_OF_CUSTOM_FIELD',
            'order' => 'ASC'

        );
        $query = new WP_Query( $args );

        <?php if ( $query->have_posts() ) : ?>

          <!-- the loop -->
          <?php while ( $query->have_posts() ) : $query->the_post(); ?>
            <!-- Staff Post HTML -->
          <?php endwhile; ?>
          <!-- end of the loop -->

          <?php //wp_reset_postdata(); ?>

        <?php else:  ?>

        <?php endif; ?>
?>

That worked, thank you very much

Is it possible to display multiple custom fields on one page?

Yes, inside the loop you simply call the_field("name_of_custom_field") for each custom field you want displayed.