Plugin Author
Baden
(@baden03)
Not sure what ACF repeater fields are, might you share a link?
http://www.advancedcustomfields.com/
So, when the site owner goes to their page, they can enter text into fields that I set up. The repeater part is that they can click “add row” and add another row. Then when I code the page, it will loop all the entries in those fields.
I am working on a temporary URL right now – can you email me and I can send you a link? [ redacted, support is not offered via email ]
Plugin Author
Baden
(@baden03)
ok, so then you are building the collapse elements programatically?
Are you using the roll-your-own method, or the shortcode?
IF you are using the shortcode, are you assigning an id attribute? If you don’t assign an ID, the shortcode will assign a (99% unique) random ID.
See code below. It will repeat the entries they enter into the ACF. So if there are two or three entries into the “job openings” field, then it’ll display two or three titles and descriptions. What I want is for all the job openings to show, then the descriptions to expand. But so far, when you click on any title, all the descriptions expand.
<?php if(get_field('job_openings')): ?>
<?php while(has_sub_field('job_openings')): ?>
<div class="collapseomatic" id="careers"><?php the_sub_field('openings'); ?></div>
<div class="collapseomatic_content" id="target-careers"><?php the_sub_field('job_description'); ?></div>
<?php endwhile; ?>
<?php endif; ?>
Plugin Author
Baden
(@baden03)
Clearly this is because you are assigning every element the same id of ‘careers’ elements should have unique id names. Try this:
<?php if(get_field('job_openings')): ?>
<?php i = 1; ?>
<?php while(has_sub_field('job_openings')): ?>
<div class="collapseomatic" id="careers<?php echo i; ?>"><?php the_sub_field('openings'); ?></div>
<div class="collapseomatic_content" id="target-careers<?php echo i; ?>"><?php the_sub_field('job_description'); ?></div>
<?php i++; ?>
<?php endwhile; ?>
<?php endif; ?>
Now with each loop we are tacking on a number that increases.
Can you dig it?
This makes total sense to me, but it’s not working… getting a syntax error when I put it in.
Nevermind, I got it! Needed a $ on the i. It’s working now. Thank you SO much! I really appreciate your help, Baden. You are my new best friend. π
Plugin Author
Baden
(@baden03)
yay! friends are my favourite ‘things’ to collect.
https://myspace.com/maxstalling/music/song/travelin-lite-47203077-50597874
yes, myspace… crazy, no?