LoginSignup
fj7839
@fj7839 (Junki Furukawa)

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

Wordpressの絞り込み検索の結果が、出力されない。

解決したいこと

カスタム投稿「concerts」から、
カスタムフィールド「status」に該当している投稿のみを検索結果として出力したいです。
以下のサイトを参考に記述していますが、投稿が一切出力されません。
原因がわからず、質問させていただきました。
初歩的なことかもしれませんが、何か気づいたことがあれば助言いただけると幸いです。

参考:https://qiita.com/takeshi_du/items/17953d3880616fc54233

該当するソースコード

<?php
    $args = array(
        'post_type' => 'concerts',
        's' =>  $_GET['s'], // 検索ワード
        'meta_query'  =>  array( // カスタムフィールド
            array(
                'key'     => 'status', // メタキー
                'value'   => $_GET['status'], // 値
            ),
        ),
    );
    $the_query = new WP_Query( $args ); 
?>

<?php if ( $the_query->have_posts() ) : ?>
    <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

    <article class="main-concerts">
        <img class="main-concerts__img" src="<?php the_field('poster'); ?>" width="335" height="458" alt="<?php the_title(); ?>">
        <div class="main-concerts__textbox">
            <div class="main-concerts__title">
            <?php $status = get_field('status'); ?>
            <?php if($status == 'sale'): ?>
                <div class="status">チケット販売中</div>
            <?php elseif($status == 'reserve'): ?>
                <div class="status">予約受付中</div>
            <?php elseif($status == 'prepare'): ?>
                <div class="status status--fin">販売準備中</div>
            <?php else: ?>
                <div class="status status--fin">終了しました</div>
            <?php endif; ?>
            <h1><?php the_title(); ?></h1>
        </div>
      ...

        <?php endwhile; ?>
    <?php endif; wp_reset_postdata(); ?>

    </section>
<?php else : ?>
...	 	
<?php endif; ?>

発生している問題・エラー

var_dump($args);

の結果が、以下のように出力されており、
クエリした投稿が$argに格納されているのは確認できました。
image.png

自分で試したこと

・get_postsでの出力も、同様に変化なしでした。

0

No Answers yet.

Your answer might help someone💌