0

I have a custom query that I created to display the team members of a company, but my client has asked whether they can have control over the order in which each team member is displayed. Is this possible?

At the moment, the default display is to order by date, but it would be great if you could actually control the order of custom post types in a query, within the admin area.

<?php while ($teamFeed->have_posts() ) : $teamFeed->the_post(); ?> <div class="container"> <a class="thumbnail" style="text-decoration: none;" href="#thumb"> <?php if (has_post_thumbnail( $post->ID )): ?> <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?> <img src="<?php bloginfo('template_directory'); ?>/thumbs.php?src=<?php echo $image[0]; ?>&w=95&h=107&zc=1" alt="<?php the_title(); ?>" /> <p style="color:#DCDADA;padding:0 0 15px;font-size:11px;line-height:1.4em;"> <?php the_title(); ?> <br /> <?php meta('position'); ?> </p> <?php endif; ?> <span> <h1><?php the_title(); ?></h1> <?php the_content(); ?> </span> </a> </div> <?php endwhile; ?>

Thanks

2
  • can you post the code?
    – ptriek
    Dec 6, 2011 at 11:21
  • Sure, but I wouldn't have thought you'd need to do anything with the actual wp-query code would you? Maybe so...anyway the original post has been edited
    – remi90
    Dec 6, 2011 at 15:35

1 Answer 1

0

You could order your custom post type with a custom field such as 'order' that your client could change for each post :

 $teamFeed = new WP_Query( array( 'meta_key' => 'order', 'orderby' => 'meta_value' ) )

Theres also a plugin to order custom post types with drag and drop functionality, but I never tried it : http://wordpress.org/extend/plugins/post-types-order/

1
  • Great stuff, the plugin seems to do the job perfectly but it's always nice to no there is an option without having to resort to the plugin. I'll perhaps use the custom field method unless I come across a situation where the plugin would really benefit my client!
    – remi90
    Dec 6, 2011 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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