0

特定のカスタム フィールドを含むすべてのワードプレス投稿を表示するページを作成しようとしています。これを行う最善の方法は、「カスタム ページ テンプレート」を作成し、新しい WP_query を使用して問題の投稿を一覧表示することだと思いました。新しい「ページ」を作成し、新しい「ページ テンプレート」を新しい WP_query に適用しましたが、ページに投稿が表示されません。このカスタム ページ テンプレートが問題の投稿を正しく一覧表示しない理由を教えてください。どんな助けでも大歓迎です!

<?php

/**

 * Template Name: Recommended Incentives


 *

 * @package WordPress

 * @subpackage Twenty_Fourteen

 * @since Twenty Fourteen 1.0

 */



get_header(); ?>



<div id="main-content" class="main-content">







    <div id="primary" class="content-area">

        <div id="content" class="site-content" role="main">


            <?php 

// args
$args = array(

    'meta_key' => 'Incentive ID',
    'meta_value' => '20'
);

// get results
$the_query = new WP_Query( $args );

// The Loop
?>
<?php if( $the_query->have_posts() ): ?>
    <ul>
    <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
        <li>
            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
        </li>
    <?php endwhile; ?>
    </ul>
<?php endif; ?>

<?php wp_reset_query();  // Restore global post data stomped by the_post(). ?>


        </div><!-- #content -->

    </div><!-- #primary -->

</div><!-- #main-content -->



<?php

get_sidebar();

get_footer();
4

1 に答える 1