0

私はphpにかなり慣れていないので、何が間違っているのかを理解するのに少し苦労しています。なんらかの理由kd_mfi_the_featured_image( 'featured-image-3', 'post' );で存在しないため(ワードプレスの管理パネルでアップロードして問題ないように見えますが)、そうではありません= trueであり、表示されません。

目標は、注目の画像-3 が存在する場合にのみ、すべての子ページの注目の画像-3 を表示することです (このプラグインを使用して複数の注目の画像を表示しています)。私の方法は次のとおりです

  1. 現在のページ ID を取得する
  2. 現在のページ ID を使用して子ページを照会する
  3. 子ページがある場合は子ページごとに投稿データを設定
  4. 子ページに Featured-image-3 があるかどうかを確認します
  5. 子ページに featuring_image-3 がある場合はそれを表示: ない場合は次の投稿を照会

customPage.php のコード

<?php if ( have_posts() ) {  /* Query and display the parent. */
while ( have_posts() ) {
the_post();
the_content();
$thispage=$post->ID;
}

} ?>

<?php $childpages = query_posts('post_type=page&post_parent='.$thispage);
if($childpages) /* display the children content  */
        foreach ($childpages as $post) :
        setup_postdata($post); 
            if (kd_mfi_the_featured_image( 'featured-image-3', 'post' )) {

                    kd_mfi_the_featured_image( 'featured-image-3', 'post' );
                    the_post_thumbnail();

            } 
            else {
                $wp_query->next_post();
            } 


        endforeach; ?>

Functions.php のコード

if( class_exists( 'kdMultipleFeaturedImages' ) ) {

    $args2 = array(
            'id' => 'featured-image-2',
            'post_type' => 'page',      // Set this to post or page
            'labels' => array(
                'name'      => 'Home Page Carousel',
                'set'       => 'Set Home Page Carousel',
                'remove'    => 'Remove Home Page Carousel',
                'use'       => 'Use as Home Page Carousel',
            )
    );

    $args3 = array(
            'id' => 'featured-image-3',
            'post_type' => 'page',      // Set this to post or page
            'labels' => array(
                'name'      => 'Product Category Hero',
                'set'       => 'Set Product Category Hero',
                'remove'    => 'Remove Product Category Hero',
                'use'       => 'Use as Product Category Hero',
            )
    );

    $args4 = array(
            'id' => 'featured-image-4',
            'post_type' => 'page',      // Set this to post or page
            'labels' => array(
                'name'      => 'Product Category Featured',
                'set'       => 'Set Product Category Featured',
                'remove'    => 'Remove Product Category Featured',
                'use'       => 'Use as Product Category Featured',
            )
    );

    new kdMultipleFeaturedImages( $args2);
    new kdMultipleFeaturedImages( $args3 );
    new kdMultipleFeaturedImages( $args4 );

}

4

0 に答える 0