Title: [Plugin: Posts 2 Posts] Default value for &#039;fields&#039;
Last modified: August 20, 2016

---

# [Plugin: Posts 2 Posts] Default value for 'fields'

 *  Resolved [daniel_not_dan](https://wordpress.org/support/users/daniel_not_dan/)
 * (@daniel_not_dan)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-default-value-for-fields/)
 * I’m building a personal movie database – this plugin is working awesomely for
   me and I’m having a lot of fun playing around with it.
 * Here’s my question:
    I’ve set it up so that I can assign a “strength of performance”
   indicator to a particular actor in a particular movie (using ‘fields’ where I’ve
   defined the movies-to-actors relationship in functions.php). I want to be able
   to see that Michael Caine was really good in Batman Begins, but not so great 
   in Jaws 4, or whatever. I initially set it up to have two values: “great”, and“
   same-old”. However, in a movie like “Harry Potter” where there are a gazillion
   actors, it gets tedious setting most of them to “same-old”. Is there a way to
   make a custom field default to a certain value unless I specify otherwise?
 * I’m not super-strong on PHP, and I’ve played around a little trying to get it
   to work, but with no luck.
 * Any ideas?
    Thanks!
 * [http://wordpress.org/extend/plugins/posts-to-posts/](http://wordpress.org/extend/plugins/posts-to-posts/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-default-value-for-fields/#post-2699049)
 * You can do this in the [development version](http://downloads.wordpress.org/plugin/posts-to-posts.zip)(
   1.3-alpha3), like so:
 *     ```
       'fields' => array(
           'role_type' => array(
               'title' => 'Performance',
               'values' => array( 'great', 'same-old' ),
               'default' => 'same-old'
           ),
       ),
       ```
   
 *  [letusrise](https://wordpress.org/support/users/letusrise/)
 * (@letusrise)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-default-value-for-fields/#post-2699116)
 * [@scribu](https://wordpress.org/support/users/scribu/) Wow, I’ve been waiting
   for this feature. 😀
 *  [John](https://wordpress.org/support/users/jsing/)
 * (@jsing)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-default-value-for-fields/#post-2699218)
 * How can this data be displayed? Here is what i have:
 *     ```
       /* Register connection */
       function svrn_connection_type() {
           $connection_args = array(
   
       'name' => 'posts_to_customers',
               'from' => 'post',
               'to'   => 'customer',
   
                   'fields' => array(
                       'type' => array(
                           'title' => __('Type', 'svrn'),
                           'values' => array(
                               'purchase' => __('POS', 'svrn'),
                               'pawn' => __('Pawn', 'svrn'),
       			'vendor' => __('Vendor', 'svrn'),
       			'sale' => __('Sale', 'svrn')
                           	),
                       )
                   )
   
           );
   
           p2p_register_connection_type($connection_args);
       }
   
       add_action( 'init', 'svrn_connection_type' );
       ```
   
 * Which works great. For getting the name of the customer I have been using:
 *     ```
       <?php
       // Find connected customers
       $connected = new WP_Query( array(
         'connected_type' => 'posts_to_customers',
         'connected_items' => get_queried_object(),
         'nopaging' => true,
       ) );
   
       // Display connected customers
       if ( $connected->have_posts() ) :
       ?>
       <ol>
       <?php while ( $connected->have_posts() ) : $connected->the_post(); ?>
       	<li><a href="<?php the_permalink(); ?>"><?php the_title();  ?></a>
       </li><br/>
       <?php echo p2p_get_meta($post->p2p_id, 'type', true );?>
       ```
   
 * I only get the title of the post but not the Type.
 * Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[Plugin: Posts 2 Posts] Default value for 'fields'’ is closed to new 
replies.

 * ![](https://s.w.org/plugins/geopattern-icon/posts-to-posts_7a8e9d.svg)
 * [Posts 2 Posts](https://wordpress.org/plugins/posts-to-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/posts-to-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/posts-to-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/posts-to-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/posts-to-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/posts-to-posts/reviews/)

 * 3 replies
 * 4 participants
 * Last reply from: [John](https://wordpress.org/support/users/jsing/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-default-value-for-fields/#post-2699218)
 * Status: resolved