Home › Forums › Front-end Issues › 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>
</div>
{/if}
<?php the_field('exchange_type'); ?>
<div class="description">
<h3>
<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>
{/for}
</span>
{/if}
</h3>
{!$item->excerpt}
</div>
</li>
</ul>
</div>
Any assistance would be really appreciated
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 http://support.ait-themes.com/categories/wp-directory
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: http://codex.wordpress.org/The_Loop
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'); ?>
with
<?php while ( have_posts() ) : the_post(); ?>'
and
<?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 wordpress.stackexchange.com – 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.
The topic ‘Issue displaying on page with multiple items’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.