Ah got it. If there is a better way to do this, please let me know, but this does work. Assigning the custom field as a meta_key and writing the string with ampersands did the trick.
‘<?php query_posts( ‘post_type=staff&meta_key=lname&orderby=meta_value&order=ASC’); ?>’
Glad you got something that works. I hate query_posts() and WP_Query class… that’s why I wrote the GetPostsQuery class for the CCTM. You’d do something like this in your template file:
<?php
$Q = new GetPostsQuery();
$args = array();
$args['post_type'] = 'staff';
$args['orderby'] = 'lname';
$args['order'] = 'ASC';
$posts = $Q->get_posts($args);
foreach ($posts as $p) {
// print stuff here, e.g. $p['post_title'];
}
?>
See http://code.google.com/p/wordpress-custom-content-type-manager/wiki/get_posts_examples
Thank you for this and please forgive my lack of PHP knowledge, but your query array is not working. I suspect that I need to re-write how custom fields are printing, but I’m unclear on how to do that, especially since I need the fields to be wrapped in divs.
This is what the whole chunk looks like:
<?php query_posts( 'post_type=staff&meta_key=lname&orderby=meta_value&order=ASC'); ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="red-left-photo"><img src="<?php print_custom_field('headshot:to_image_src'); ?>"/></div>
<div class="red-left-box"><p class="staff-title"><?php print_custom_field('fname'); ?>
<?php print_custom_field('lname'); ?> - <?php print_custom_field('title'); ?></p>
<?php print_custom_field('education'); ?>
<span class="red">___</span>
<?php print_custom_field('education2'); ?>
<span class="red">___</span>
<?php print_custom_field('education3'); ?>
</div>
<?php endwhile; // end of the loop. ?>
If I replace the top line string with your array, then nothing prints. How can I re-write this? Thanks for your help and for this awesome plugin.
[Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your posted code may now have been permanently damaged/corrupted by the forum’s parser.]