Forum Replies Created

  • Thanks so much for the reply. I was making this way more complicated than it needed to be. The Taxonomy Field:

    $selected = get_field('selected_tags');

    was already returning an array of IDs making my variable:

    $selectags = implode(",",$selected);

    completely unnecessary. Working code is below. Hopefully it’ll save somebody else some time & trouble.

    $postnumber = get_field('number_of_posts');
    //custom field for posts per page
    $selected = get_field('selected_tags');
    // ACF Taxonomy Field (Return Value = Term ID)
    <?php $args = array(
    	'posts_per_page' => $postnumber,
    	'orderby'        => 'post_date',
    	'order'          => 'ASC',
     	'post_type'      => 'post',
     	'post_status'    => 'publish',
    	'tag__in'        => $selected
    ); ?>
    <?php query_posts($args); if (have_posts()) :
          while (have_posts()) : the_post(); ?>
             <h2><?php the_title(); ?></h2>
             <p><?php the_excerpt(); ?></p>
             <a href="<?php the_permalink() ?>">read the post</a>
             <p><?php the_tags('Tags: ', ', ', ''); ?></p>
    <?php endwhile; endif; ?>
    <?php wp_reset_query(); ?>
Viewing 1 post (of 1 total)