Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using Posts 2 Posts to display a custom post type on a page. Document status, document author and feedback due date are custom fields. Package is a custom taxonomy.

I want to display my custom post type objects grouped by custom taxonomy.

My code displays as:

Title
Package:
Document Status:
Document Author:
Feedback due date:

Title
Package:
Document Status:
Document Author:
Feedback due date:

Title
Package:
Document Status:
Document Author:
Feedback due date:

How do I display it as (grouped by Package name)?

Package:

Title
Document Status:
Document Author:
Feedback due date:

Title
Document Status:
Document Author:
Feedback due date:

Title
Document Status:
Document Author:
Feedback due date:

Package

Title
Document Status:
Document Author:
Feedback due date:

Title
Document Status:
Document Author:
Feedback due date:

Package

Title
Document Status:
Document Author:
Feedback due date:

...etc

My current code is below:

// Display connected pages
if ( $connected->have_posts() ) :
?>

<ul>
<?php while ( $connected->have_posts() ) : $connected->the_post(); ?>
    <li>
        <a href="<?php echo get_post_meta($post->ID, 'ecpt_doc_source',    true); ?>"><?php the_title(); ?></a><br/>
        <p><?php echo cc_get_the_term_list( $post->ID, 'packages', 'Package: ', ', ', '', 0 ); ?><br/>
        Document status: <?php echo get_post_meta($post->ID, 'ecpt_doc_status', true); ?><br/>
        Document author: <?php echo get_post_meta($post->ID, 'ecpt_doc_author', true); ?><br/>
        Feedback due date: <?php $due_date = get_post_meta($post->ID, 'ecpt_doc_fb_date', true);
        echo date('j F, Y', $due_date);?>
        </p>                                
    </li>
<?php endwhile; ?>
</ul>

<?php 

wp_reset_postdata();

endif;

Can you help me solve this?

Thank you!

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.