Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // FUNCTIONS.PHP CODE
- add_action( 'wp_loaded', 'my_connection_types' );
- function my_connection_types() {
- // Make sure the Posts 2 Posts plugin is active.
- if ( !function_exists( 'p2p_register_connection_type' ) )
- return;
- p2p_register_connection_type( array(
- 'name' => 'books_to_series',
- 'from' => 'books',
- 'to' => 'series'
- ) );
- p2p_register_connection_type( array(
- 'name' => 'excerpts_to_books',
- 'from' => 'book_excerpt',
- 'to' => 'books',
- ) );
- p2p_register_connection_type( array(
- 'name' => 'praise_to_books',
- 'from' => 'book_praise',
- 'to' => 'books',
- ) );
- }
- // TMPL-BOOKS.PHP CODE
- <?php
- $my_query = new WP_Query( array(
- 'post_type' => 'series',
- 'nopaging' => true,
- //'order' => 'ASC',
- //'orderby' => 'menu_order',
- ) );
- p2p_type( 'books_to_series' )->each_connected( $my_query, array(), 'books' );
- while ( $my_query->have_posts() ) : $my_query->the_post();
- $current_series_id = get_the_ID();
- $current_series_content = get_the_content();
- ?>
- <section class="post-content clearfix">
- <h3 class="h2"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
- <?php
- // Display connected books
- foreach ( $post->books as $post ) : setup_postdata( $post );
- // testing to see if anything displays at all in the foreach loop (it doesn't if running 1.4 but everything shows in 1.3.1):
- echo 'hello!';
- if (function_exists('vp_get_thumb_url')) {
- $thumb=vp_get_thumb_url($post->post_content, 'medium');
- if ($thumb!='') { ?>
- <a href="<?php the_permalink(); ?>"><img class="coverimg" src="<?php echo $thumb; ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?> by Sherri Browning Erwin" /></a>
- <?php } else { ?>
- <div class="cover">
- <img src="<?php echo $url; ?>/wp-content/uploads/no-cover.png" alt="<?php the_title(); ?>" title="<?php the_title(); ?> by Sherri Browning Erwin" />
- </div><!-- .cover -->
- <?php }
- }
- endforeach;
- if($current_series_content !== "") { ?>
- <div class="series-desc"><?php echo $current_series_content; ?></div><!-- .series-desc -->
- <?php }
- wp_reset_postdata();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement