Want more features on Pastebin? Sign Up, it's FREE!
Guest

Posts 2 Post plugin - missed connections

By: coneff on Dec 10th, 2012  |  syntax: PHP  |  size: 2.81 KB  |  views: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /* Posts 2 Posts v1.4.3 */
  3. /* function.php */
  4. function connection_types() {
  5.   if ( !function_exists( 'p2p_register_connection_type' ) )
  6.     return;
  7.   p2p_register_connection_type( array(
  8.     'name' => 'posts_to_artists',
  9.     'from' => 'post',
  10.     'to' => 'artists',
  11.     'title' => array( 'from' => 'Connected Artists', 'to' => 'Connected Posts' )
  12.   ) );
  13.   p2p_register_connection_type( array(
  14.     'name' => 'posts_to_series',
  15.     'from' => 'post',
  16.     'to' => 'series',
  17.     'title' => array( 'from' => 'Connected Series', 'to' => 'Connected Posts' )
  18.   ) );
  19. }
  20. add_action( 'p2p_init', 'connection_types' );
  21. ?>
  22. /* theme */
  23.         <?php
  24.         // Find connected pages
  25.         $connected = new WP_Query( array(
  26.           'connected_type' => 'series_to_posts',
  27.           'connected_items' => get_queried_object(),
  28.           'posts_per_page'=>3, // Enter the Number of posts that will be shown.
  29.         ) );
  30.  
  31.         // Display connected pages
  32.         if ( $connected->have_posts() ) :
  33.         ?>
  34.         <h3 id="related">Videos in series</h3>
  35.         <ul class="posts posts-3 grid">
  36.         <?php
  37.          $i = 0;
  38.         while ( $connected->have_posts() ) : $connected->the_post();
  39.         $i++;
  40.         ?>
  41.                 <li<?php if ($i == 3) {$i = 0; echo " class=\"last\"";} ?>>
  42.                 <?php unset($img); if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail() ) {
  43.                         $thumbURL = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), '' );
  44.                         $img = $thumbURL[0];  }
  45.                          else {
  46.                                 unset($img);
  47.                                 if ($wpzoom_cf_use == 'Yes')   {  $img = get_post_meta($post->ID, $wpzoom_cf_photo, true);   }
  48.                         else  {
  49.                                 if (!$img) { $img = catch_that_image($post->ID);  }
  50.                                 } }
  51.                         if ($img){ $img = wpzoom_wpmu($img); ?>
  52.                         <div class="cover"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo $img ?>&amp;h=155&amp;w=210&amp;zc=1" alt="<?php the_title(); ?>"/></a></div><?php } ?>
  53.  
  54.                 <div class="postcontent">
  55.                         <h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><span class="speaker-name"><?php the_title(); ?></span></a></h2>
  56.                         <p class="postmetadata"><?php if ($wpzoom_homepost_date == 'Show') { ?><?php the_time("$dateformat"); ?><?php } ?><?php if ($wpzoom_homepost_date == 'Show' && $wpzoom_homepost_cat == 'Show') { ?> / <?php } ?><?php if ($wpzoom_homepost_cat == 'Show') { ?><?php the_category(', '); ?><?php } ?><br />
  57.                         <?php echo get_post_meta($post->ID, 'talk_location', true) ?></p>
  58.  
  59.                         <?php the_excerpt(); ?>
  60.  
  61.                         <?php if ($wpzoom_homepost_more == 'Show') { ?><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" class="readmore" rel="nofollow">read more</a><?php } ?> <?php edit_post_link( __('Edit this post', 'wpzoom'), ' | ', ''); ?>
  62.  
  63.                 </div>
  64.                  </li>
  65.        
  66.         <?php endwhile; ?>
  67.         </ul>
  68.  
  69.         <?php
  70.         // Prevent weirdness
  71.         wp_reset_postdata();
  72.  
  73.         endif;
  74.         ?>
clone this paste RAW Paste Data