LoginSignup
3
0

More than 5 years have passed since last update.

Wordpress 固定ページの「親」の項目が表示されない

Posted at

これは F氏から相談を受けたものの、首をひねるしかなく、結局 本人が解決に導いたトラブルなのだが、有用な情報源が見当たらなかったので 共有のために記す

現象

固定ページ または 階層が有効のカスタム投稿タイプ で、親となるページを用意していたつもりの上で子ページを作ろうとしたら、メタボックスに 親ページ の項目が表示されなかった

原因

つもり」 というのは、まだ公開してはならないコンテンツだったため、親ページを 非公開 で保存していた。のだが、これだと Wordpress は 「親ページがない」 ので 「メタボックスに項目を表示しない」 という仕様だった

もう少し具体的に言うと、post_status が publish かどうかを見ていた

解決策

  • 該当のページへの動線を隠したまま、親ページを公開・子ページの登録、という方法
  • publish 以外も含まれるように フィルターフック で追加する

ドキュメントには書かれていたのか

一応の解決を見たものの、気になったので公式ドキュメントを確認してみた。日本語版は古い (最終更新が2009年だった) ので、英語版を確認

公式ドキュメントの固定ページの項 (To create a subpage - Pages « WordPress Codex) から引用

  1. Go to Administration > Pages > Add New screen.
  2. In the right menu, click the "Page Parent" drop-down menu. The drop-down menu contains a list of all the Pages already created for your site.
  3. Select the appropriate parent Page from the drop-down menu to make the current Page a child Page.
  4. Add content to the subpage.
  5. Click Publish when ready.

とある。本件での肝は、

The drop-down menu contains a list of all the Pages already created for your site.

訳すとすれば 「ドロップダウンメニューには、あなたのサイトの すべての作成済みページ のリストが含まれている」 だが、個人的には 公開済み (published) と書くべきと思う…

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0