Last active
May 15, 2018 13:14
-
-
Save obiPlabon/bb9de6a18278a3c43869fd3c5af696e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Show only top level district or division | |
* that means district without any parent district | |
* | |
* @param array $args | |
* @return array $args | |
*/ | |
function op_page_attributes_dropdown_pages_args( $args ) { | |
if ( 'district' === $args['post_type'] ) { | |
$args['depth'] = 1; | |
} | |
return $args; | |
} | |
add_filter( 'page_attributes_dropdown_pages_args', 'op_page_attributes_dropdown_pages_args' ); | |
add_filter( 'quick_edit_dropdown_pages_args', 'op_page_attributes_dropdown_pages_args' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Register Custom Post Type | |
function op_register_post_type() { | |
$labels = array( | |
'name' => _x( 'Districts', 'Post Type General Name', 'khutkhut' ), | |
'singular_name' => _x( 'District', 'Post Type Singular Name', 'khutkhut' ), | |
); | |
$args = array( | |
'labels' => $labels, | |
'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes' ), | |
'hierarchical' => true, | |
'public' => true, | |
'menu_icon' => 'dashicons-location', | |
); | |
register_post_type( 'district', $args ); | |
} | |
add_action( 'init', 'op_register_post_type', 0 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ..... lots of things are here | |
$dropdown_args = array( | |
'post_type' => $post->post_type, | |
'exclude_tree' => $post->ID, | |
'selected' => $post->post_parent, | |
'name' => 'parent_id', | |
'show_option_none' => __('(no parent)'), | |
'sort_column' => 'menu_order, post_title', | |
'echo' => 0, | |
); | |
/** | |
* Filters the arguments used to generate a Pages drop-down element. | |
* | |
* @since 3.3.0 | |
* | |
* @see wp_dropdown_pages() | |
* | |
* @param array $dropdown_args Array of arguments used to generate the pages drop-down. | |
* @param WP_Post $post The current post. | |
*/ | |
$dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post ); | |
$pages = wp_dropdown_pages( $dropdown_args ); | |
// ..... lots of things are here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment