This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 7th, 2012  |  syntax: None  |  size: 1.78 KB  |  views: 30  |  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.  
  3. function my_connection_types() {
  4. p2p_register_connection_type( array(
  5.         'name' => 'workout',
  6.         'from' => 'workout',
  7.         'to' => 'workout',
  8.         'cardinality' => 'one-to-many',
  9.         'title' => array( 'from' => 'connected from', 'to' => 'connected to' )
  10. ));
  11. }
  12. add_action( 'p2p_init', 'my_connection_types' );
  13.  
  14.  
  15. function order_pages_by_title( $args, $ctype, $post_id ) {
  16.         if ( 'workout' == $ctype->name) {
  17.                 $args['orderby'] = 'title';
  18.                 $args['order'] = 'asc';
  19.         }
  20.  
  21.         return $args;
  22. }
  23.  
  24. add_filter( 'p2p_connectable_args', 'order_pages_by_title', 10, 3 );
  25.  
  26.  
  27. add_action( 'init', 'codex_custom_init' );
  28. function codex_custom_init() {
  29.  
  30.   $labels = array(
  31.     'name' => _x('Workout', 'post type general name'),
  32.     'singular_name' => _x('Workout', 'post type singular name'),
  33.     'add_new' => _x('Add New', 'book'),
  34.     'add_new_item' => __('Add New Workout'),
  35.     'edit_item' => __('Edit Workout'),
  36.     'new_item' => __('New Workout'),
  37.     'all_items' => __('All Workouts'),
  38.     'view_item' => __('View Workout'),
  39.     'search_items' => __('Search workouts'),
  40.     'not_found' =>  __('No workouts found'),
  41.     'not_found_in_trash' => __('No workout found in Trash'),
  42.     'parent_item_colon' => '',
  43.     'menu_name' => 'Workout'
  44.  
  45.   );
  46.   $args = array(
  47.     'labels' => $labels,
  48.     'public' => true,
  49.     'publicly_queryable' => true,
  50.     'show_ui' => true,
  51.     'show_in_menu' => true,
  52.     'query_var' => true,
  53.     'rewrite' => true,
  54.     'capability_type' => 'page',
  55.     'has_archive' => true,
  56.     'hierarchical' => true,
  57.     'menu_position' => null,
  58.     'supports' => array( 'custom-fields', 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments','page-attributes'  ),
  59.     'taxonomies' => array('category','post_tag')
  60.   );
  61.   register_post_type('workout',$args);
  62. }
clone this paste RAW Paste Data