確かに親子ページの予約は使う可能性がゼロでは無いと思いますが、要望ならここに書くよりもここで書いた方が良いと思います。
一応、フォーラムのタイトルは提案となってますが、余程ニーズのあるような内容ならまだしも…
とりあえず回避策として
手段其の一
post_parent
等の名前でカスタムフィールドを作ってそこへ親ページIDを入れて予約すれば公開されていな状態で親子関係が設定できます。
function set_post_parent( $data, $postarr ) {
$parent_id = get_post_meta( $postarr['ID'], 'post_parent', true );
if( $parent_id ){
$data['post_parent'] = $parent_id;
}
return $data;
}
add_filter( 'wp_insert_post_data', 'set_post_parent', 99, 2 );
手段其の二
下書きだろうが非公開だろうが予約だろうがおかまいなしで親の選択肢に含めます。
要らなければprivate
とdraft
は消してください。
function my_post_parent( $output, $r, $pages ) {
$args = array(
'post_type' => 'page',
'post_status' => 'publish,private,draft,future'
);
$pages = get_pages( $args );
$output = '';
if ( empty( $r['id'] ) ) {
$r['id'] = $r['name'];
}
if ( ! empty( $pages ) ) {
$class = '';
if ( ! empty( $r['class'] ) ) {
$class = " class='" . esc_attr( $r['class'] ) . "'";
}
$output = "<select name='" . esc_attr( $r['name'] ) . "'" . $class . " id='" . esc_attr( $r['id'] ) . "'>\n";
if ( $r['show_option_no_change'] ) {
$output .= "\t<option value=\"-1\">" . $r['show_option_no_change'] . "</option>\n";
}
if ( $r['show_option_none'] ) {
$output .= "\t<option value=\"" . esc_attr( $r['option_none_value'] ) . '">' . $r['show_option_none'] . "</option>\n";
}
$output .= walk_page_dropdown_tree( $pages, $r['depth'], $r );
$output .= "</select>\n";
}
return $output;
}
add_filter( 'wp_dropdown_pages', 'my_post_parent', 10, 3 );
どちらでも好きな方でどうそ。
随分昔のトピックですが、WP Total Hackプラグインをインストールして、そのプラグイン設定で、公開されていないページを親にして、子ページを作ることができます。
参考:https://firegoby.jp/archives/3597