page_attributes_meta_box

Display page attributes form fields.

Description

page_attributes_meta_box( (object) $post ); 

Parameters (1)

0. $post (object)
The post.

Usage

  1. if ( !function_exists( 'page_attributes_meta_box' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/meta-boxes.php'; 
  3.  
  4. // The post. 
  5. $post = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = page_attributes_meta_box($post); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/meta-boxes.php  
  1. function page_attributes_meta_box($post) { 
  2. if ( is_post_type_hierarchical( $post->post_type ) ) : 
  3. $dropdown_args = array( 
  4. 'post_type' => $post->post_type,  
  5. 'exclude_tree' => $post->ID,  
  6. 'selected' => $post->post_parent,  
  7. 'name' => 'parent_id',  
  8. 'show_option_none' => __('(no parent)'),  
  9. 'sort_column' => 'menu_order, post_title',  
  10. 'echo' => 0,  
  11. ); 
  12.  
  13. /** 
  14. * Filters the arguments used to generate a Pages drop-down element. 
  15. * @since 3.3.0 
  16. * @see wp_dropdown_pages() 
  17. * @param array $dropdown_args Array of arguments used to generate the pages drop-down. 
  18. * @param WP_Post $post The current WP_Post object. 
  19. */ 
  20. $dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post ); 
  21. $pages = wp_dropdown_pages( $dropdown_args ); 
  22. if ( ! empty($pages) ) : 
  23. ?> 
  24. <p class="post-attributes-label-wrapper"><label class="post-attributes-label" for="parent_id"><?php _e( 'Parent' ); ?></label></p> 
  25. <?php echo $pages; ?> 
  26. <?php 
  27. endif; // end empty pages check 
  28. endif; // end hierarchical check. 
  29.  
  30. if ( count( get_page_templates( $post ) ) > 0 && get_option( 'page_for_posts' ) != $post->ID ) : 
  31. $template = ! empty( $post->page_template ) ? $post->page_template : false; 
  32. ?> 
  33. <p class="post-attributes-label-wrapper"><label class="post-attributes-label" for="page_template"><?php _e( 'Template' ); ?></label><?php 
  34. /** 
  35. * Fires immediately after the label inside the 'Template' section 
  36. * of the 'Page Attributes' meta box. 
  37. * @since 4.4.0 
  38. * @param string $template The template used for the current post. 
  39. * @param WP_Post $post The current post. 
  40. */ 
  41. ?></p> 
  42. <select name="page_template" id="page_template"> 
  43. <?php 
  44. /** 
  45. * Filters the title of the default page template displayed in the drop-down. 
  46. * @since 4.1.0 
  47. * @param string $label The display value for the default page template title. 
  48. * @param string $context Where the option label is displayed. Possible values 
  49. * include 'meta-box' or 'quick-edit'. 
  50. */ 
  51. $default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'meta-box' ); 
  52. ?> 
  53. <option value="default"><?php echo esc_html( $default_title ); ?></option> 
  54. <?php page_template_dropdown( $template, $post->post_type ); ?> 
  55. </select> 
  56. <?php endif; ?> 
  57. <?php if ( post_type_supports( $post->post_type, 'page-attributes' ) ) : ?> 
  58. <p class="post-attributes-label-wrapper"><label class="post-attributes-label" for="menu_order"><?php _e( 'Order' ); ?></label></p> 
  59. <input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr( $post->menu_order ); ?>" /> 
  60. <?php if ( 'page' == $post->post_type && get_current_screen()->get_help_tabs() ) : ?> 
  61. <p><?php _e( 'Need help? Use the Help tab above the screen title.' ); ?></p> 
  62. <?php endif; 
  63. endif;