Home Forums Front-end Issues Issue displaying on page with multiple items


Issue displaying on page with multiple items

  • Hi,

    Great plugin. Have been able to add fields on pages which has info for the 1 post using

    <?php the_field('exchange_type'); ?>

    but on a category page where there are details for multiple items when I insert the same code it displays the output for the first entry on every entry on the page.

    The code I am trying to add into is:

    	<div class="category-items clearfix">
    		<ul n:foreach="$posts as $item" class="items">
    			<li class="item clear{ifset $item->packageClass} {$item->packageClass}{/ifset}">
    				{if $item->thumbnailDir}
    				<div class="thumbnail">
    					<img src="{timthumb src => $item->thumbnailDir, w => 100, h => 100}" alt="{__ 'Item thumbnail'}">
    					<div class="comment-count">{$item->commentsCount}</div>
    				<?php the_field('exchange_type'); ?>
    				<div class="description">
    						<a href="{!$item->link}">{$item->title}</a>
    						{if $item->rating}
    						<span class="rating">
    							{for $i = 1; $i <= $item->rating['max']; $i++}
    								<span class="star{if $i <= $item->rating['val']} active{/if}"></span>

    Any assistance would be really appreciated

  • Hi @cosmicfantasia

    Looks like your loop is a query template. Is this correct?

  • Hi, I’m not sure. How can I find out?

    FYI, the theme is the Directory theme from AIT

  • Hi @cosmicfantasia

    Sorry mate, this support forum is not here to debug your theme and write code for you.

    Perhaps you should read over the ACF docs to learn more about what ACF is and what it does.

  • ok, appreciate that. From reading over the docs, not sure on the terminolgy or what direction I should be going in. ie. What’s a loop?

    Is a loop what I’m looking @? ie. on the category page which has a number of listings, is that where a loop is used?

  • Yeah, generally whenever you have multiple “posts” being listed you are using a loop (literally “looping through” them). While this is not a WordPress-specific concept, you can read about it (in the context of WP) here:

  • Thank you. That’s very help ful and has given a better understaning @ what I’m trying to do here.

    Just not sure what the issue is that I’m having.

    Have tried wrapping the

    <?php the_field('exchange_type'); ?>

    <?php while ( have_posts() ) : the_post(); ?>'


    <?php endwhile; ?>

    with differing results. When it is wrapped directly around thefield code it displays nothing, when wrapped around the whole div it displays the listings twice, but again doesn’t show the out put to the field.

    Without that code it shows the field result, but repeats the value for the first entry in a loop for the other entries.

    Hoping somebody could @ least give us a lead as to a way forward.

    Thank you

  • Would you be able to assist if we we’re to purchase the WYSIWYG and Gallery add-ons? Need to find a way one way or another to be able to get the custom fields on other page.

  • Any developers you recommend to pay for getting this sorted?

  • check out – those guys and gals will help you out. Make sure you do your due diligence first though. Study up on the codex. Use google.

    In general, make an effort to solve your issue, but if you get stuck, post a question on stackexchange. If you post this one there, I’ll see if I can answer. The ACF support guys are here to troubleshoot ACF specific issues.

    Best of luck.

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

The topic ‘Issue displaying on page with multiple items’ is closed to new replies.