Home Forums General Issues user to sort and filter ACF list Reply To: user to sort and filter ACF list

  • Hi @vince_m

    You don’t have to follow the code on the page I gave you before. It’s only an example how to do it. I’m sorry I forgot to tell you that.

    The following is a simple example to do it.

    <?php if ( isset($_GET['searchkey']) ){ ?>
        // args
        $args = array(
            'numberposts'	=> -1,
            'post_type'	=> 'custom-post-type',
            'meta_query'	=> array(
                    'key'		=> 'athlete',
                    'value'		=> $_GET['searchathlete'],
                    'compare'	=> 'LIKE'
        // query
        $the_query = new WP_Query( $args );
        <?php if( $the_query->have_posts() ): ?>
            <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
                    <a href="<?php the_permalink(); ?>">
                        <img src="<?php the_field('event_thumbnail'); ?>" />
                        <?php the_title(); ?>
            <?php endwhile; ?>
        <?php endif; ?>
        <?php wp_reset_query(); ?>
    <?php } //endif isset searchkey?>

    Then you can get the posts like this:

    Where “searchkey” is the athlete you want to search. This page should give you more idea about it:

    I hope this makes sense 🙂