Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function show_directory() {
- $args = array(
- 'post_status' => 'publish',
- 'orderby' => 'meta_value',
- 'order' => 'asc',
- 'posts_per_page' => -1,
- 'nopaging' => true,
- 'suppress_filters' => false,
- 'connected_type' => 'directory_to_projects',
- 'connected_direction' => 'to',
- 'connected_items' => 'any',
- );
- $dir_query = new WP_Query($args);
- if ($dir_query->have_posts()) : while ($dir_query->have_posts()) : $dir_query->the_post();
- global $post;
- the_title();
- p2p_type( 'directory_to_projects' )->each_connected( $dir_query );
- echo '<ul>';
- foreach ( $post->connected as $post ) : setup_postdata( $post ); ?>
- <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
- <?php
- endforeach;
- echo '</ul>';
- wp_reset_postdata();
- endwhile;
- endif;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement