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.

Here's the website: KunzlerIP

At the bottom of the website, you see a slider using Fancybox. Each thumbnail pops up some content from an individual custom post type post. For this custom post type, I've enabled the following:

    function post_type_lawyers() {
    register_post_type( 'lawyers',
        array( 
            'label' => __('Lawyers'),
            'public' => true,
            'show_ui' => true,
            'hierarchical' => true,
            'supports' => array(
                'title',
                'thumbnail',
                'page-attributes',
                'post-thumbnails',
                'custom-fields',
                'revisions',
                )
        )
    ); //end register_post_type
    register_taxonomy( 'lawyer', 'lawyers', array( 'hierarchical' => true, 'label' => __('Rank') ) );
}
add_action('init', 'post_type_lawyers');

The info for each pop-up is a custom field value and key. Currently, there are 4 values per individual post.

What I would like to do is order these custom field values in the following order:

  • Height
  • Fueled By
  • Favorite Quote
  • Areas of Expertise

If you go through these pop-ups, you'll see that a couple of them don't follow the same order for some reason and I can't figure out how to control how they display.

To call this slider, here's the query:

    <ul id="lawyers">
    <?php query_posts('post_type=lawyers&orderby=date&order=DESC&posts_per_page=-1'); while (have_posts()): the_post(); ?>
        <li>
            <a href="#<?php the_ID(); ?>" class="fancybox"><?php the_title(); echo the_category(); if ( has_post_thumbnail() ) { the_post_thumbnail(); } ?></a>
            <div id="<?php the_ID(); ?>" class="profile"><?php if ( has_post_thumbnail() ) { the_post_thumbnail('large', array('class' => 'baseball')); } ?><h3><?php the_title(); ?></h3><?php echo(the_meta()); ?></div>
        </li>
    <?php endwhile; ?>
</ul>

Does it have something to do with the_meta()?

share|improve this question
    
This depends more on your query than register post type, it would be better to post that code instead, since it most likely involves something like orderby=meta_value&order=ASC –  Wyck Jul 19 '11 at 1:22
    
@Wyck, I think I added what you wanted to see, but I'm not sure. Let me know if I still haven't posted it yet. –  micah Jul 19 '11 at 1:47
add comment

1 Answer

the function the_meta() formats the data into an unordered list and you have no control over the order. Instead you should use get_post_custom() and echo out only the fields you want and in the order you want.

change:

<?php echo(the_meta()); ?>

to :

    $post_custom =  get_post_custom($post->ID);
    echo '<ul>';
    echo '<li>'.$post_custom['Height'].'</li>';
    echo '<li>'.$post_custom['Fueled_By'].'</li>';
    echo '<li>'.$post_custom['Favorite_Quote'].'</li>';
    echo '<li>'.$post_custom['Areas_of_Expertise'].'</li>';
    echo '</ul>';

and change the name of the fields to match yours.

share|improve this answer
    
I tried your method and the only result I got back is the word "array". –  micah Jul 19 '11 at 18:29
1  
Add [0] after each field eg; $post_custom['Fueled_By'][O] –  Bainternet Jul 19 '11 at 19:33
    
That's a good start but no dice. I added four [0] values after each field and it only returns the value of the ['Height'] field. Nothing else shows up, including the key. I want both the key and the value to show. Thus, I want the word "Height" and the answer to both show up. –  micah Jul 19 '11 at 20:06
1  
If you want the key then add the key to the output as for nothing else showing up that means that you didn't change the names of the fields to match yours like i posted. –  Bainternet Jul 19 '11 at 20:23
1  
I suggest you read and learn a bit about custom fields so you would understand what key or field name means, if you read my answer it says change the names of the fields which means copy paste won't work –  Bainternet Jul 20 '11 at 4:42
show 3 more comments

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.