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 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

share|improve this question
    
can you post the code? –  ptriek Dec 6 '11 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 '11 at 15:35
add comment

1 Answer

up vote 0 down vote accepted

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/

share|improve this answer
    
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 '11 at 16:23
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.