John,
Thanks again for your help. That fixed it!
Daniel
Actually, it shows even when error reporting is off. So i’ll have to fix it somehow
So i’ve been using the syntax to get the count of a repeater’s rows from this thread successfully until I recently upgraded my PHP from 5 to 7. After upgrading to 7, I get the following warning:
Warning: count(): Parameter must be an array or an object that implements Countable in /nfs/c06/h08/mnt/153609/domains/mydomain.com/html/wp-content/themes/mytheme/template-name.php on line 135
The code in the template is as follows:
<?php $count = count(get_field("locations")); ?>
I then use the count in a conditional if/then statement.
It all still works, but throws the warning if php error reporting is on and I like to resolve it, but not sure how.
John,
Thanks for pointing me to the two functions as a starting point. I was able to put together the following, and it worked perfect. Appreciate the help.
Code:
function my_acf_save_post( $post_id ) {
// get new value
$costInDollars = get_field('cost_in_dollars');
$discountInDollars = get_field('discount_in_dollars');
// do something
$totalCostInDollars = $costInDollars - $discountInDollars;
update_field('total_cost_in_dollars', $totalCostInDollars, $post_id);
}
add_action('acf/save_post', 'my_acf_save_post', 20);
Im trying to do the exact same thing with one simple modification to make the main loop ORDER_BY ASC a custom field value in the related post called “artist_last_name”.
Elliot – can you advise how to modify this to get the main loop to order by a value in the related post’s custom field?
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.