Support

Account

Home Forums Add-ons Repeater Field Repeating Field in Category Template

Solving

Repeating Field in Category Template

  • Hi guys,

    I have a custom post type. This custom post type has a repeating image field associated with it.

    I use the following code to display the image in the archive.php template.

    <?php if( have_rows('ges_case_study') ): while ( have_rows('ges_case_study') ) : the_row(); ?>
        <img src="<?php the_sub_field('case_study_img');?>" alt="Global Energy Systems - Case Studies" />
        <?php break; //Using break here because I only want to display the first image of the repeating field ?>
        <?php endwhile;
        else : // no rows found ?>
        <?php endif; ?>

    This displays the first image added in the repeating field section. When I display the single-custom-post-type.php i display them all.

    Everything works perfectly.

    The problem is in my category.php template.

    In my category template I use the same code, but no image is displaying.

    So if somebody goes to http://www.mywebsite.com/case_studies/industrial for example, the posts for that category display but the image doesn’t.

    I am using the wordpress ‘the_title’ and ‘the_permalink’. these display. Just not the acf field.

    Can anybody point me in the right direction. The image displays on every other page I need it too.

    • Stronky

    • February 1, 2019 at 11:39 am

    First of all try to let it show on all possible pages and check if it’s still “missing”. If shows up then you know that u need to make some fixes in your field group display settings. Hope it helps.

  • Hi,

    The images display on every page other than the individual category pages.

    I have checked my rules and I have it set to.

    Show this field group if -> Post Type is equal to Case Study.

    I am guessing I need to add to this rule setting to get the image to output on the front end?

    If so what do I need to change?

    Thanks

    Dan

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.