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 trialDharmesh Sheth
2,547 PointsWordpress Custom Fields
how to add 'order attributes option' on Advanced Custom Fields
Dharmesh Sheth
2,547 PointsHi 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?
Andrew Shook
31,709 PointsYes, see my answer below.
2 Answers
Andrew Shook
31,709 PointsSo 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; ?>
?>
Dharmesh Sheth
2,547 PointsThat worked, thank you very much
Dharmesh Sheth
2,547 PointsIs it possible to display multiple custom fields on one page?
Andrew Shook
31,709 PointsYes, inside the loop you simply call the_field("name_of_custom_field") for each custom field you want displayed.
Andrew Shook
31,709 PointsAndrew Shook
31,709 PointsI'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.