frankl23
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Plugins
In reply to: [Posts 2 Posts] [Plugin: Posts 2 Posts] List of possible connections?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.
Forum: Plugins
In reply to: [Posts 2 Posts] [Plugin: Posts 2 Posts] List of possible connections?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!
Viewing 2 replies - 1 through 2 (of 2 total)