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.

OK, very simple task, I'm just not good at PHP.

I have a page where I want to list some staff using a styled list. Here is the page all working fine, I just need to divide the results - http://www.themontessoripeople.co.uk/montesori/?post_type=people

I downloaded a "custom content type" plugin and added the content type of "people" and added the appropriate fields. Now I want to filter the posts I have added by the custom field called "hierarchy".

Here is how I want the page to display - http://i47.tinypic.com/oqymwh.jpg

Notice in the image I have headings for each group of posts filtered by the room. The custom field "hierarchy" contains the room variables of either "management", "babies_room" and "toddlers_room".

How do I amend the code below to filter the posts by the value held within <?php print_custom_field('hierarchy'); ?> ?

<?php $col = 1; ?>      
    <?php if (have_posts()) : ?>        
        <?php while (have_posts()) : the_post(); ?>         
            <?php if ($col == 1) echo "<div class=\"row\">"; ?>

                <div class="post col<?php echo $col;?>" id="post-<?php the_ID(); ?>">

                            <div class="people-spacer">

                                <div class="people"><a class="animate" >
                                <div class="bio">
                                <p class="titles"><?php the_title(); ?><br/>
                                <span class="job"> <?php print_custom_field('job'); ?></span> </p><br />
                                </div>
                                <img src="<?php print_custom_field('staff_image:to_image_src'); ?>" width="160" height="160" alt="<?php the_title(); ?>-image" />
                                </div>
                                <div class="people-link-edit"><?php edit_post_link('Edit Post', ''); ?></div>
                            </div>
                </div>

            <?php if ($col == 1) echo "</div>"; (($col==1) ? $col=2 : $col=2); ?>   
        <?php endwhile; ?>

Thanks, Ben.

share|improve this question
add comment

1 Answer

Something like this should work:

meta_key=hierarchy&meta_value=management

This should be added into the query_posts function, that is not shown in your code block, but should come before it.

share|improve this answer
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.