Title: Custom Field GUI Utilityで親固定ページで子ページに設定したフィールド表示
Last modified: 2016年7月30日

---

# Custom Field GUI Utilityで親固定ページで子ページに設定したフィールド表示

 *  解決済 [t.harada](https://ja.wordpress.org/support/users/tharada/)
 * (@tharada)
 * [15年、 3ヶ月前](https://ja.wordpress.org/support/topic/custom-field-gui-utility%e3%81%a7%e8%a6%aa%e5%9b%ba%e5%ae%9a%e3%83%9a%e3%83%bc%e3%82%b8%e3%81%a7%e5%ad%90%e3%83%9a%e3%83%bc%e3%82%b8%e3%81%ab%e8%a8%ad%e5%ae%9a%e3%81%97%e3%81%9f%e3%83%95%e3%82%a3/)
 * Custom Field GUI Utilityを使って親の固定ページで子の固定ページに設定したカスタム
   フィールドを表示したいのですが、やり方が分かりません。
 * 現在は親ページのテンプレートに以下のように記述していますが、カスタムフィールド
   に設定した部分は何も表示されません。
 *     ```
       <ul class="thumb">
   
       <?php
       $children = get_pages('parent=209&hierarchical=0');
       foreach ($children as $child) {
       ?>
       <?php
       foreach ($children as $child) {
       $eye_catch = get_post_thumbnail_id($child->ID);
       ?>
   
       <li>
       <!-- アイキャッチ画像とタイトル表示 -->
       <?php echo post_custom('textfield_business')?>
       <a href="<?php echo get_page_link($child->ID);?>"><?php echo wp_get_attachment_image($eye_catch, $size=array(212,212));?></a><br>
       <a href="<?php echo get_page_link($child->ID);?>"><?php echo esc_html($child->post_title);?></a>
       </li>
   
       <?php }?>
   
       <?php }?>
       </ul>
       ```
   
 * `<?php echo post_custom('textfield_business')?>`
    を他の関数のように `<?php echo
   $child->post_custom('textfield_business')?>` と変えても以下のようなエラーが出
   ます。 `Fatal error: Call to undefined method stdClass::post_custom() in /hogehoge.
   php on line 26`
 * 子ページ自体を表示している際のカスタムフィールドは問題なく表示されます。
    この
   場合、どのように記述すれば宜しいのでしょうか？ 他のプラグインやヒントだけでも
   頂ければ幸いです。

1件の返信を表示中 - 1 - 1件目 (全1件中)

 *  トピック投稿者 [t.harada](https://ja.wordpress.org/support/users/tharada/)
 * (@tharada)
 * [15年、 2ヶ月前](https://ja.wordpress.org/support/topic/custom-field-gui-utility%e3%81%a7%e8%a6%aa%e5%9b%ba%e5%ae%9a%e3%83%9a%e3%83%bc%e3%82%b8%e3%81%a7%e5%ad%90%e3%83%9a%e3%83%bc%e3%82%b8%e3%81%ab%e8%a8%ad%e5%ae%9a%e3%81%97%e3%81%9f%e3%83%95%e3%82%a3/#post-141547)
 * 自己レスです。
 * フォーラムにあった[こちら](http://ja.forums.wordpress.org/topic/2914?replies=7)
   のポストを参考にして、以下のように書き換えてみたところ、うまく行きました。
 *     ```
       <ul class="thumb">
       <?php
       if ( $post->post_parent == ID209) {
       	$child_posts = get_posts( '&order=ASC&orderby=date&post_type=page&meta_key=textfield_business' );
       	if ( $child_posts ) {
       		foreach ( $child_posts as $child ) {
       			$eye_catch = get_post_thumbnail_id($child->ID);
       			$c_pagelink = get_page_link( $child->ID );
       			$c_title = apply_filters( 'the_title', $child->post_title );
       			$c_business = get_post_meta( $child->ID, textfield_business, true );
       			$c_name = get_post_meta( $child->ID, textfield_name, true );
       ?>
       <li><a href="<?php echo $c_pagelink; ?>"><?php echo wp_get_attachment_image($eye_catch, $size=array(212,212));?><br />
       <span class="text10"><?php echo $c_business; ?></span><br />
       <?php echo $c_name; ?></a>
       </li>
       <?php
       		}
       	}
       }
       ?>
       </ul>
       ```
   
 * このコードでCustom Field GUI Utilityを使う意味があるのかは謎ですが…（汗
    もう少し
   スマートなコードがあれば是非お教えいただきたいです。

1件の返信を表示中 - 1 - 1件目 (全1件中)

 トピック「Custom Field GUI Utilityで親固定ページで子ページに設定したフィールド表示」
には新たに返信することはできません。

## タグ

 * [カスタムフィールド](https://ja.wordpress.org/support/topic-tag/%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e3%83%95%e3%82%a3%e3%83%bc%e3%83%ab%e3%83%89/)
 * [Custom Field Gui Utility](https://ja.wordpress.org/support/topic-tag/custom-field-gui-utility/)

 * フォーラム: [プラグイン](https://ja.wordpress.org/support/forum/plugins/)
 * 1件の返信
 * 1人の参加者
 * 最後の返信者: [t.harada](https://ja.wordpress.org/support/users/tharada/)
 * 最後の活動: [15年、 2ヶ月前](https://ja.wordpress.org/support/topic/custom-field-gui-utility%e3%81%a7%e8%a6%aa%e5%9b%ba%e5%ae%9a%e3%83%9a%e3%83%bc%e3%82%b8%e3%81%a7%e5%ad%90%e3%83%9a%e3%83%bc%e3%82%b8%e3%81%ab%e8%a8%ad%e5%ae%9a%e3%81%97%e3%81%9f%e3%83%95%e3%82%a3/#post-141547)
 * 状態: 解決済

## トピック

### 人気のトピック

### 返信がないトピック

### サポート関連ではないトピック

### 解決済みのトピック

### 未解決のトピック

### すべてのトピック
