1

I doing make a filter with wp_query for a custom post type. I create my page and I want to include a filter by date (year) with wp_query

<?php


get_header();
?>
<div class="row">
    <div class="container">
        <?php
if ( have_posts() ) {
    while ( have_posts() ) {
    the_post(); 
    ?>
        <div class="col-md-3 col-12 event test">

            <a href="<?php the_permalink(); ?>" title="lien vers">
                <div>
                    <h2><?php the_title(); ?></h2>
                </div>
                <img class="event-thumbnail" src="<?php echo get_the_post_thumbnail_url()?>" />

                <?php
                  the_field('date');
                ?>
            </a>
        </div>

        <?php
    }

}

?>
    </div>
</div>

<?php
get_footer();

and i do make a selector for the visitor so they can chose year

if you have a answer take me

sorry for my english i'm frensh student (lycéen)

  • the first step is to add a form with "method=GET" where the user can choose the year. – Kaperto Dec 3 '19 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.