• Is it possible to list possible connections to make between post types, rather than having the search box?

    I would like to limit the search to only those custom post types that the current author has made. There should only be 4 to 5, so I’d like to present a list of checkboxes for them rather than having to search for each one.

    Is this possible?

    http://wordpress.org/extend/plugins/posts-to-posts/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author scribu

    (@scribu)

    Yes, it’s possible, but you will need some coding skills to make your own metabox. See:

    http://wordpress.org/support/topic/plugin-posts-2-posts-how-to-add-info-to-connection/page/2#post-1686691

    Thread Starter frankl23

    (@frankl23)

    Thanks for the starting point scribu. I’ve built this and it gives me the list of the author’s ‘widgets’ (custom post type), but only after I’ve searched for something and added a connection. I haven’t been able to find any examples of, or figure out, how to remove the search box from the default box (and remove the descriptive text) and display my list in its place. I’m also missing a piece for saving the selected items.

    Any pointers would be much appreciated.

    function my_p2p_init() {
    
    	class My_P2P_Box_Multiple extends P2P_Box_Multiple {
    
    		function connection_template ( $post_id = 0, $p2p_id = 0 ) {
    			if ( $post_id ) {
    				$post_title = get_the_title( $post_id );
    			} else {
    				$post_id = '%post_id%';
    				$post_title = '%post_title%';
    			}
    			$user_id = get_current_user_id( );
    			$result = new WP_Query("post_type=widgets&post_status=publish&author=$user_id&orderby=title");
    			foreach ( $result->posts as $current_post ) {
    ?>
    				<li>
    					<label>
    						<input type="checkbox" name="<?php echo $this->input_name( array( 'post_id', '' ) ); ?>" value="<?php echo $current_post->ID; ?>">
    						<?php echo $current_post->post_title; ?>
    					</label>
    				</li>
    <?php
    			}
    ?>
    			<li>
    				<label>
    					<input type="checkbox" checked="checked" name="<?php echo $this->input_name( array( 'post_id', '' ) ); ?>" value="<?php echo $post_id; ?>">
    					<?php echo $post_title; ?>
    				</label> < p2p
    			</li>
    <?php
    		}
    	}
    
    	p2p_register_connection_type( array(
    		'from' => 'items',
    		'to' => 'widgets',
    		'box' => 'My_P2P_Box_Multiple',
    	) );
    }
    add_action('init', 'my_p2p_init');

    Cheers!

    Thread Starter frankl23

    (@frankl23)

    As an aside, I know I have two ‘li’ blocks in there, one is your original block (which displays the items I search for and add connection to) and the first one is my new one for the list. The final version will obviously only have one of these.

    Nick Davis

    (@esanctuary)

    Hi frankl, did you manage to get this working the way you wanted it in the end? I am really keen on limiting P2P in my set-up to only allow authors to link to other posts they created

    It sounds like you were also trying to do similar?

    I did try your code but it didn’t work in my instance unfortunately

    I realise it was a while ago now but any pointers you can give would really be much appreciated

    Thanks

    Nick (eSanctuary)

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Posts 2 Posts] List of possible connections?’ is closed to new replies.