@jjrohrer I wound up doing something like this:
https://gist.github.com/jancbeck/3178689
to add each user’s role as a classname on the body. Then used an admin style sheet to hide the field.
That just served to make me feel bad! 🙂
Perhaps to more seasoned developers the changes are obvious but I tried diffing the two templates with the Code Area add-on and didn’t get very far via trial and error. Perhaps, time permitting, a “foo” is now “bar” would be handy for those of us in the trenches trying to update other people’s add-ons? Would be for me anyway!
There is an HTML editor on the ACF WYSIWYG editor. Click the last button on the right to reveal an extra row of buttons. You’ll see the HTML button there.
Looks like this is no longer true as of WP 3.9 (on FC/Repeaters anyway). Anyone know how to get it back?
I think @faeronsayn is asking if there is a way to get ACF to recognize existing post_meta on a post and incorporate it/them into a field group assigned to that post.
If so, I’d probably create the new fields and turn to SQL but I’ve been watching this question to see if there is another way (in case I ever spend any significant time updating older pre-ACF-as-religion sites).
@shanomurphy agreed. I just tried to use it to include a small set of fields more than once within a large field group. Works great but all of the fields wind up with the same values as the first. Presumably this is because all of the fields included, no matter how many times, share the same field key from the original field group (like field_5303024b1c357]
).
I don’t know enough about the innards of ACF to bend the plugin to my will (though I tried!).
Ahhhhhhhhhhhh! THANK YOU!
Makes total sense – it was getting the next row each time so it only echoed the 2nd and 4th items.
Follow up: the wall I ran into the first time I tried the non setup_postdata
method was that you can’t pass an id to get_the_excerpt()
. I rewrote the entire loop without the setup_postdata
stuff and made my own excerpt function. All is working swimmingly. Thanks again.
Thanks Elliot. Yes, that works well. I had that going at first but ran into some other wall that got me to look at the docs and try the setup_postdata()
route.
I’ll mark this as solved and file it mentally under ‘setup_postdata function can cause many problems with the global $post object.‘ I’m having other problems on the page now with conditionals and sub_field values which I’ll chalk up to that too! Will retry your suggested method.
ACF has a nice set of filters. You are probably looking for acf/load_field
I think you need to use get_field_object
but don’t quote me – I’m learning as well. 🙂
$choices = get_field_object('yourFieldKey');
http://www.advancedcustomfields.com/resources/functions/get_field_object/
Hi @deeve007
I can’t reproduce that. Both versions output the selected item and the selected item only.
Do you see the incorrect value when you debug all fields?
<?php
$fields = get_fields();
echo "<pre>";
print_r($fields);
echo "</pre>";
?>
When you edit the post again, is the first value selected or the one you thought you’d selected?
Hi @KimH,
Hmm, I just tried a test and it seems to be working fine. 0/No is selected and when I look at the source in firebug, that input has checked=""checked""
as an attribute. I copy and pasted your code block above into a radio field.
1 : Yes
0 : No
Is it possible some other javascript on the page is selecting the first one? Are you sure what you have above is what’s in the choices field. Looks like you already know this but the spaces around the colons are important.
Try moving this code
$attachment_id = get_field('slide_photo');
$size = "medium"; // (thumbnail, medium, large, full or custom size)
$image = wp_get_attachment_image_src( $attachment_id, $size );
into your loop. Outside of the loop, there’s no way to know what get_field('slide_photo')
is referring to.
Hi @Phil_Hart,
This code samples for getting a random repeater item should help: http://www.advancedcustomfields.com/resources/field-types/repeater/#wpshdo_4
There is an HTML editor on the ACF WYSIWYG editor. Click the last button on the right to reveal an extra row of buttons. You’ll see the HTML button there. Sadly, once you’ve entered HTML, the next time you open it it’s a complete mess (all line breaks and white space removed). There may be a setting to fix that, I haven’t looked into it.
What @sixfootjames said.
are you seeing any javascript errors in the console? which browser are you using? Which version of wordpress? version of ACF?
Wow, good stuff. Thanks for figuring it out @daniel@push10.com
Favorited for recall!
I just realized that you can use negative numbers when setting the order. I wonder if that’ll wake it up. 🙂
I wish WordPress had a way to zap the PRAM sometimes.
Hi @janmalagu
You can find a user list on “Field Type” -> “Relational” -> “User”. You can also set it to be a multi select.
Not quite sure what you’re toggling with but something like this should do it with the DOM structure you have there.
jQuery('.leden-details').on('click', function(){
$(this).next('.leden-show').toggle();
});
The next()
is the trick.
Just tested and this is working as expected for me. Are both of your field groups set the same with regard to “position” (After title, after content…)? I didn’t work initially for me but I had one of my groups set to “High (After Title)”.
It sorta provides it, just not inside of the sizes array. It’s up a level under [“url’]. This is the same as the image field’s return.
I reckon it would be good for consistency with the WP API to also include [“full”] within the [“sizes”] array.
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.