When I try to use this solution, I get PHP warnings:
PHP Warning: implode() [function.implode]: Invalid arguments passed in /Applications/MAMP/htdocs/wp-content/themes/theme2016/page-our-team.php on line 127
What do I need to adjust?
$team = get_field('team');
$team = array_map('sanitize_title', $team);
$team = implode(' ', $team );
team field is a Checkbox in a custom post type if it matters.
Think I figured it out. Rather than put it in the actual page template, it goes in the functions.php:
// Function to randomize Advanced Custome Fields' Repeaters
function my_acf_load_value3( $value, $post_id, $field )
{
shuffle($value);
return $value;
}
// Randomize ACF Clients' Repeater
add_filter('acf/load_value/name=clients', 'my_acf_load_value3', 10, 3);
So should it be as simple as inserting it like this:
<?php if( have_rows('clients') ): ?>
<?php
function my_acf_load_value3( $value, $post_id, $field )
{
shuffle($value);
return $value;
}
add_filter('acf/load_value/name=clients', 'my_acf_load_value3', 10, 3);
?>
<div class="outerContainer clientGrid clearfix">
<?php while( have_rows('clients') ): the_row();
// vars
$name = get_sub_field('client_name');
$img = get_sub_field('logo');
$docVid = get_sub_field('doc_or_vid');
$docURL = get_sub_field('document_location');
$vidURL = get_sub_field('video_url');
?>
<div class="clientItem clearfix <?php the_sub_field('areas'); ?>">
<?php if($docURL && $docVid == 'doc'): ?>
<a target="_blank" class="clientLink" href="<?php echo $docURL; ?>">
<span class="sprite"></span>
</a>
<?php endif; ?>
<?php if($vidURL && $docVid == 'vid'): ?>
<a target="_blank" class="clientLink clientVid external" href="<?php echo $vidURL; ?>">
<span class="sprite"></span>
</a>
<?php endif; ?>
<?php if( $img ): ?>
<img class="client-logo" src="<?php echo $img; ?>" alt="<?php echo $name; ?>" />
<?php endif; ?>
</div>
<?php endwhile; ?>
</div><!-- ./clientGrid -->
<?php endif; ?>
Just typing it up here and formatting it helped me work it out in my head:
<?php if( have_rows('press_releases') ): ?>
<h2>Press Releases <span class="sprite icon"></span></h2>
<div>
<?php endif; ?>
<?php
$prRows = get_field('press_releases' ); // get all the rows
$first_row = $prRows[0]; // get the first row
$first_row_year = $first_row['year'];
$first_row_pr = $first_row['pr_posts'];
?>
<h3><?php echo $first_row_year; ?></h3>
<?php
if($first_row_pr)
{
foreach($first_row_pr as $pr)
{
echo '<h4><a href="#">' . $pr['heading'] . '</a></h4>';
echo '<p>' . $pr['date'] . '</p>';
}
}
?>
John,
Yeah, the complication that’s throwing me through a loop (pun intended) is the getting the first row and then the syntax to loop through that nested repeater.
Yeah, I wanted a dropdown list of posts from a given post category. I was able to accomplish it by using the Field Type Post Object.
I had it set to filter by post type (Post) and then filter by Taxonomy (Specific Category)
Then I created a set of custom fields for that specific category for other information I wanted to display/output.
All set. Thanks for attempting to assist.
I see this is in the “solving” phase. Any ETA on when a fix will be pushed out?
Thanks, Elliot. I looked at Flexible Content Field briefly, but not fully understanding its power/usage. Might be time to buy a license of that for home and work.
You have any examples of it in practice along the lines of what I’m looking to do?
Not sure if this will help, but to give you an idea of what my ACF field group looks like:
And this is the first select expanded:
Think I am experiencing this as well. I’m creating a fairly complex set of ACFs and just ran into a point where when I go to save a new field, it disappears as soon as I save (update).
Is there a known limit to the number of fields Field Group?
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.