Advertisement
Guest User

P2p function

a guest
May 24th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.82 KB | None | 0 0
  1. <?php
  2. p2p_register_connection_type( array(
  3.     'name' => 'posts_to_invitations',
  4.     'from' => 'post',
  5.     'to' => 'invitations',
  6.     'sortable' => 'any',
  7.     'admin_dropdown' => 'from',
  8.     'admin_column' => 'from',
  9.     'fields' => array(
  10.         'couples' => array(
  11.             'title' => 'Couples',
  12.             'type' => 'checkbox'
  13.         ),
  14.         'going' => array(
  15.             'title' => '# Going',
  16.             'type' => 'select',
  17.             'values' => array( 'No Response','Not Going', '1', '2', '3', '4', '5', '6', '7', '8' )
  18.         ),
  19.  
  20.         'attend' => array(
  21.             'title' => '# Attend',
  22.             'type' => 'select',
  23.             'values' => array( 'Not Attending', '1', '2', '3', '4', '5', '6', '7', '8' )
  24.  
  25.         ),
  26.         'comments' => array(
  27.             'title' => 'Comments',
  28.             'type' => 'text',
  29.         ),
  30.         'table' => array(
  31.             'title' => '# Table',
  32.             'type' => 'select',
  33.             'values' => array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50'  )
  34.  
  35.         ),
  36.     )
  37. ) );
  38.  
  39. // Find connected pages
  40. $connected = new WP_Query( array(
  41.   'connected_type' => 'posts_to_invitations',
  42.   'connected_items' => get_queried_object(),
  43.   'nopaging' => true,
  44. ) );
  45.  
  46. // Display connected pages
  47. if ( $connected->have_posts() ) :
  48. ?>
  49. <h3>Related pages:</h3>
  50. <ul>
  51. <?php while ( $connected->have_posts() ) : $connected->the_post(); ?>
  52.     <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
  53. <?php endwhile; ?>
  54. </ul>
  55.  
  56. <?php
  57. // Prevent weirdness
  58. wp_reset_postdata();
  59.  
  60. endif;
  61. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement