Ah, duh! I think I was thinking I needed to because the Modern Tribe shortcode for The Events Calendar was just rendering as text and not working as a shortcode… so I was thinking I had to do something more.
I’m realizing now that the shortcode isn’t working because we don’t have the PRO version of the Events Calendar Plugin: https://theeventscalendar.com/knowledgebase/shortcodes/
Thanks for the response.
Does this work if you have a shortcode in a WYSIWYG field that is in an ACF flexible content field? I’m not having any luck with it.
When you find your own confirmation of the solution from the same problem 6 months ago…
https://support.advancedcustomfields.com/forums/topic/count-repeater-items/
“Have to make the count before “have_rows””
I am also having this exact issue. I have a flexible content field and one of the options is a repeater. I want to know how many items are in the repeater in order to set a class, but it’s returning “1” instead of what should be “2” or “3.”
@martinkolle — THANK YOU. This was driving me bonkers (always getting 1 on a nested repeater within a flexible content field. This worked.
I totally forgot about this… may have to reference it myself sometime, ha!
I also just ran into this — and this is the second time. I can’t remember how I solved it the first time, but I don’t think it had anything to do with URE. This time, though, deactivating URE does help.
Wow, thank you so much! I really appreciate the help. I will spend some time reviewing this.
I’m also looking to solve a similar problem: I would like a select field to populate some text fields with related data. (My Select field is populated with custom taxonomy items, each of which have custom fields. I want their custom field data to populate the text fields.).
Any luck with this?
Hello,
I am having the same problem. And I have removed my line — the one calling the relationship field — and without it the archive page works fine. It’s definitely the relationship field. I’ve tried both ways of querying/displaying relationship fields, too.
Any ideas on this?
I have used ACF on custom sites a number of times since November 2013 and haven’t run into this issue before. But I did today… using PRO. Maybe the issue exists in the PRO version?
I was able to figure it out thanks to this:http://wordpress.stackexchange.com/questions/78826/inserting-gravity-form-checkbox-values-into-advanced-custom-fields
One thing I ran into is that if I needed the serialized value for a field, the “get_post_custom_values” function worked. Otherwise, the ACF “get_field” function was what I needed for other types of fields.
add_action("gform_after_submission_2", "acf_post_submission", 10, 2);
function acf_post_submission ($entry, $form)
{
$post_id = $entry["post_id"];
// funding status
$values = get_field("reviewer_funding_status", $post_id);
echo "<br />reviewer_funding_status: " . $values;
update_field("field_519f97aab12f7", $values, $post_id);
// rating - overall
$values = get_field("rating_overall", $post_id);
echo "<br />rating_overall: " . $values;
update_field("field_519f989ab12f8", $values, $post_id);
// rating - clarity of mission
$values = get_field("rating_clarity_of_mission", $post_id);
echo "<br />rating_clarity_of_mission: " . $values;
update_field("field_520be9eac3f72", $values, $post_id);
// rating - communications
$values = get_field("rating_communications", $post_id);
echo "<br />rating_communications: " . $values;
update_field("field_519f98d4b12f9", $values, $post_id);
// rating - evaluation
$values = get_field("rating_evaluation", $post_id);
echo "<br />rating_evaluation: " . $values;
update_field("field_520be9fdc3f73", $values, $post_id);
// funder ID
$values = get_post_custom_values("funder_id", $post_id);
echo "<br />funder_id - serialized: " . $values;
update_field("field_519f996ce16ca", $values, $post_id);
}
Thanks, I’ll give this a try!
Thanks, Elliot! I will give this a shot.
All right, I think I found all the connections…
We’ve got:
I found it… The file is stored in the wp_posts table as a post_type of attachment and a post_parent ID of the record in question. I think I’m still missing something, though, because I still don’t see how it is tied to the field itself…
Today I ran into more “not saving” issues. I made a screenr video so you can see: http://www.screenr.com/96pH
BUT THEN. It occurred to me that maybe WP Engines caching was affecting this somehow. I “purged all caches” and then things started saving. I’m asking them about it, but I’m thinking maybe that was the issue, not something with ACF.
Another, possibly related one:
I created a field. Then I renamed it and moved it. It stayed in the new location just fine. Then I decided to rename it again. Each time I renamed it and Updated the field group it did not save. Until save #4. Then it did. Again, no Firebug errors.
Just ran into one of the issues I’d seen before. I drag and drop a new field from the bottom to a new location, but it doesn’t save. There are no errors in Firebug.
Sorry, didn’t think to save those… will add them next time I run into anything.
Okay, this works. But, holy schnikes, that’s a lot of work for one little list!
<label>Presenter: </label>
<?php
#----------------- GET THE DISTINCT LIST OF SERIALIZED PRESENTERS FROM PRESENTATIONS
$presenter_id_array = array();
$presenter_data = $wpdb->get_col(
"SELECT DISTINCT wp_postmeta.meta_value FROM wp_posts
INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)
WHERE 1=1 AND wp_posts.post_type = 'presentations' AND (wp_posts.post_status = 'publish') AND (wp_postmeta.meta_key = 'presenters' )
GROUP BY wp_posts.ID ");
#----------------- LOOP THROUGH THAT LIST
foreach ($presenter_data as $presenter_data_item)
{
#----------------- DO A QUERY TO GET A SPECIFIC PRESENTATION POST
$args = array(
'post_type' => 'presentations',
'posts_per_page' => -1,
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'presenter',
'value' => $presenter_data_item,
'compare' => '=',
)
)
);
$custom_loop = new WP_Query($args);
#echo "<br /><br >". $custom_loop->request;
#----------------- GET THAT PRESENTATION'S DATA
if( $custom_loop->have_posts() ):
while( $custom_loop->have_posts() ): $custom_loop->the_post();
#----------------- GET THE PRESENTER RELATIONSHIP FIELD DATA
$posts = get_field('presenter');
if( $posts ):
foreach( $posts as $post_object):
#----------------- FINALLY, GET THAT STAFF ID OUT OF THE RELATIONSHIP FIELD!!!!
#----------------- ADD IT TO MY LIST OF STAFF IDS
array_push($presenter_id_array,$post_object->ID);
endforeach;
endif;
endwhile;
endif;
}
#----------------- NOW, DO A QUERY FOR A SUBSET OF STAFF WHO ARE PRESENTERS
$args = array(
'post_type' => 'staff-members',
'posts_per_page' => -1,
'post_status' => 'publish',
'order' => 'ASC',
'orderby' => 'title',
'post__in' => $presenter_id_array
);
$custom_loop = new WP_Query($args);
#echo "<br /><br >". $custom_loop->request;
?><select name="search_presenter">
<option value="">-</option>
<?php if( $custom_loop->have_posts() ):
while( $custom_loop->have_posts() ): $custom_loop->the_post();
?><option value="<?php get_the_id(); ?>"><?php the_title(); ?></option><?php
endwhile;
endif;
// Reset Query
wp_reset_postdata(); ?>
</select>
Also, to clarify, the value I’m getting back for the presenter in that $presenter_data query is a serialized item like this:
a:1{i:0;s:2:"71";}
71 is the ID I’m trying to get. I realize I could use some PHP to manipulate this, just seems like there must be a better way.
So, later on, I realized that this is not the right way to go about it. Really what I want is a subset of a CPT called “staff.” I want to get the staff who are presenters on my CPT called “presentations.”
Therefore, it seems like I should do a query on “staff” but just get the ones whose ID is used in the presentations. Right?
$args = array(
'post_type' => 'staff-members',
'posts_per_page' => -1,
'post_status' => 'publish',
'order' => 'ASC',
'orderby' => 'title',
'post__in' => $presenter_id_list
);
However, this starts getting way more complicated than it seems like it should… in order to get the $presentation_id_list data, I can get the distinct list of presenters here:
$presenter_data = $wpdb->get_col(
"SELECT DISTINCT wp_postmeta.meta_value FROM wp_posts
INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)
WHERE 1=1 AND wp_posts.post_type = 'presentations' AND (wp_posts.post_status = 'publish') AND (wp_postmeta.meta_key = 'presenters' )
GROUP BY wp_posts.ID ");
But that gives me an array of the serialized “presenter” relationship field. How do I get at the ID in that relationship field??? This seems like it is getting way more complicated than it needs to be. Am I missing something?
Thanks!
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.