I have 3 Custom Post Types (CPTs)
The CPTs:
- Attorney CPT
- Practice Groups CPT (i.e. General Business, Maritime, etc)
- Areas of Concentration CPT (i.e. Litigation, Toxic Torts, etc.)
The Connections:
Each attorney practices in 1 or more Areas of Concentration and so uses p2p to connect Attorneys to Areas of Concentration (atty_to_aoc).
Each Area of Concentration belongs in 1 of 4 Practice Groups and so uses p2p to connect Areas of Concentration to Practice Group (aoc_to_practice_group).
The Problem:
- On attorney-single.php, I'm trying to display a list of all the Practice Groups to which an attorney belongs.
- However there is no connection between Attorney and Practice Group CPTs, only between Areas of Concentration and Practice Groups (aoc_to_practice_group).
- So I am trying (without success) to find a way to get the practice groups to show on attorney-single.php
- The code below (incorrectly) shows the Areas of Concentration not the (desired) Practice Groups.
The Code:
function displayAttyPracticeGroup(){
// Add multiple connections
$connected_type = array('aoc_to_practice_group', 'atty_to_aoc');
// Find connected pages
$new_query = new WP_Query( array(
'connected_type' => $connected_type,
'connected_items' => get_queried_object_id(),
'nopaging' => true,
'post_type' => array('practice'),
) );
if ( $new_query->have_posts() ) : ?>
<ul class="list-unstyled">
<li><strong>Practice Groups</strong></li>
<?php while ( $new_query->have_posts() ) : $new_query->the_post(); ?>
<li><?php echo get_the_title(); ?></li>
<?php endwhile; ?>
<?php endif; ?>
</ul>
<?php
wp_reset_postdata();
}
Aucun commentaire:
Enregistrer un commentaire