Hi I’m a noob making a wordpress theme and I’ve already made my custom post types(called ‘members’), made custom fields for that post type, and have tagged the posts i want to call in (tag name’domestic_tax_consulting’). What I want to do is to call in all tagged posts onto a page and print just the featured image + 4 specific custom fields from those posts. Oh and for custom fields im using a plugin called ACF.

So basically i have a custom post type of members that each have tags according to the project they are working on, and on the project page i want to print info of the members who are currently working on that project.

here is my code

<?php get_header (); ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
    <div class="row">
        <div class="small-6 medium-3 float-right">
            <?php $custom_query = new WP_Query(array(
            'post_status' => 'publish',
            'post_type' => 'members',
            'tag_slug__in' => 'domestic_tax_consulting',
            'posts_per_page' => -1
            )); 
            while ($custom_query->have_posts()) : $custom_query->the_post(); ?>
            <div class="member_container">  
                <div class="img"><?php the_post_thumbnail(); ?></div>
                <p><?php the_field('members_name'); ?></p>
                <p><?php the_field('members_position'); ?></p>
                <p><?php the_field('members_e-mail'); ?></p>
                <p><?php the_field('members_phone'); ?></p>
            </div>
        <?php endwhile; ?>
        </div>  
    </div>
<?php endwhile; ?>
<?php endif; ?>
<?php get_footer (); ?>

Read more here: call custom fields from tagged posts wordpress (ACF)


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: