Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function my_connection_types() {
- p2p_register_connection_type( array(
- 'name' => 'workout',
- 'from' => 'workout',
- 'to' => 'workout',
- 'cardinality' => 'one-to-many',
- 'title' => array( 'from' => 'connected from', 'to' => 'connected to' )
- ));
- }
- add_action( 'p2p_init', 'my_connection_types' );
- function order_pages_by_title( $args, $ctype, $post_id ) {
- if ( 'workout' == $ctype->name) {
- $args['orderby'] = 'title';
- $args['order'] = 'asc';
- }
- return $args;
- }
- add_filter( 'p2p_connectable_args', 'order_pages_by_title', 10, 3 );
- add_action( 'init', 'codex_custom_init' );
- function codex_custom_init() {
- $labels = array(
- 'name' => _x('Workout', 'post type general name'),
- 'singular_name' => _x('Workout', 'post type singular name'),
- 'add_new' => _x('Add New', 'book'),
- 'add_new_item' => __('Add New Workout'),
- 'edit_item' => __('Edit Workout'),
- 'new_item' => __('New Workout'),
- 'all_items' => __('All Workouts'),
- 'view_item' => __('View Workout'),
- 'search_items' => __('Search workouts'),
- 'not_found' => __('No workouts found'),
- 'not_found_in_trash' => __('No workout found in Trash'),
- 'parent_item_colon' => '',
- 'menu_name' => 'Workout'
- );
- $args = array(
- 'labels' => $labels,
- 'public' => true,
- 'publicly_queryable' => true,
- 'show_ui' => true,
- 'show_in_menu' => true,
- 'query_var' => true,
- 'rewrite' => true,
- 'capability_type' => 'page',
- 'has_archive' => true,
- 'hierarchical' => true,
- 'menu_position' => null,
- 'supports' => array( 'custom-fields', 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments','page-attributes' ),
- 'taxonomies' => array('category','post_tag')
- );
- register_post_type('workout',$args);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement