SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | function show_directory() {
| |
| 3 | $args = array( | |
| 4 | 'post_status' => 'publish', | |
| 5 | 'post_type' => 'directory', | |
| 6 | 'meta_key' => 'faculty_last', | |
| 7 | 'orderby' => 'meta_value', | |
| 8 | 'order' => 'asc', | |
| 9 | 'posts_per_page' => -1, | |
| 10 | - | 'connected_type' => 'directory_to_projects', |
| 10 | + | |
| 11 | - | 'connected_direction' => 'to', |
| 11 | + | |
| 12 | - | 'connected_items' => 'any', |
| 12 | + | |
| 13 | $dir_query = new WP_Query($args); | |
| 14 | ||
| 15 | p2p_type( 'directory_to_projects' )->each_connected( $dir_query ); | |
| 16 | ||
| 17 | if ($dir_query->have_posts()) : while ($dir_query->have_posts()) : $dir_query->the_post(); | |
| 18 | global $post; | |
| 19 | ||
| 20 | // CONDITIONAL: IF THE DIRECTORY ITEM HAS A CONNECTION IN THE 'FROM' DIRECTION, AND THE CONNECTION TYPE IS DIRECTORY_TO_PROJECTS, DISPLAY IT | |
| 21 | if ( $post->connected && $post->connected[0]->p2p_from && ( $post->connected[0]->p2p_type == 'directory_to_projects' ) ) {
| |
| 22 | ||
| 23 | the_title(); | |
| 24 | ||
| 25 | p2p_type( 'directory_to_projects' )->each_connected( $dir_query ); | |
| 26 | echo '<ul>'; | |
| 27 | foreach ( $post->connected as $post ) : setup_postdata( $post ); ?> | |
| 28 | <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> | |
| 29 | ||
| 30 | <?php | |
| 31 | endforeach; | |
| 32 | echo '</ul>'; | |
| 33 | wp_reset_postdata(); | |
| 34 | ||
| 35 | } // end conditional | |
| 36 | endwhile; | |
| 37 | endif; | |
| 38 | } | |
| 39 | ?> |