Home › Forums › Pre-purchase Questions › AFC to work with jetpack shortcodes
I am using AFC for the input fields of recipes.
Jetpack recipe shortcodes work nicely in wp’s post input field but not in custom fields.
Anything I can do to get jetpack shortcodes to work with ACP?
Compatibility plans for upcoming plugin update?
Don’t see this in Pro either…
See the documentation for the acf/format_value filter. It has an example of what needs to be done to use shortcodes in ACF fields https://www.advancedcustomfields.com/resources/acfformat_value/
Almost there, thank you John!
Following your link, I plugged the code into the client’s child theme functions.php:
function my_acf_format_value( $value, $post_id, $field ) {
// run do_shortcode on all textarea values
$value = do_shortcode($value);
// return
return $value;
}
add_filter(‘acf/format_value/type=textarea’, ‘my_acf_format_value’, 10, 3);
What am I missing?
Here’s the result with no change:
http://dermutanderer.de/de/knusprige-gans-mac-cheese-mit-dem-aeg-procombi-plus/
Is the field type you’re using and trying to add the shortcode to a textarea field or something else? That’s about he only thing I can see that might be off.
Right again, John
The field I am trying to add the shortcode to is defined as WYSIWYG Editor (German translation). Want me to replace “textarea” with “wysiwyg editor” (or look up the correct english expression.
Thank you again.
All shortcodes should be run in wysiwyg fields by default, so we’re back to your original problem. The shortcodes should be working without adding any code.
Try changing “textarea” to “wysiwyg”
add_filter('acf/format_value/type=wysiwyg', 'my_acf_format_value', 10, 3);
what version of ACF are you using?
Version 4.4.11
I switched both, the Acf field and the coding to “textarea” – did not work
Keeping it at Wysiwyg editor and trying wysiwyg – didn’t work
I am reading through the documentary on the look out for further options.
I just look through the code of ACF4 and any shortcodes added to wysiwyg fields should work without any extra code. I don’t use jetpack, but if these shortcodes work the same as any other wp shortcodes then there should be no reason that they don’t work unless there is something else on the site that’s interfering. I’d say to disable other plugins, but, while I don’t use jetpack, I am familiar with it and there are reasons that I don’t use it.
And that made me think of something else. How are you getting the value of the ACF field to display on your pages?
Well than k your very much John.
How am I getting the value of the ACF field to display on my pages? No sure if I understand:
Same as through a blog entry only its an AFC field entry…
I tested the possible variations, here’s what I got
Both combinations are working:
1) With AFC set to textfield and html tags conversion.
2) With AFC set to textfield and carriage return conversion to <br />.
3) AFC set to WYSIWYG Editor in any combination not working.
What works only works with a new blog post set up.
It is not working when the AFC fields simply get updated after the field setting is changed to reflect the the right setting (1&2).
Anything I can do to get 850 entries to work upon editing and updating?
You’ve completely lost me I think.
If you create a new post then it works as expected but if make a change to and existing value then it is not updated?
Do you have some type of a cache in place that needs to be cleared?
It sounds like something is being cached in some way, possibly by something in jetpack.
I don’t know what “850 entries” refers to in your last post.
When I asked how do the values in ACF get to your content, for most applications it requires modification to template files to display ACF field content. If you do not use calls to ACF functions and edit code then there is something else that is reading the values of the fields and adding them to your content.
Yes it sounds like a caching thing but can’t be. No caching whatsoever.
The 850 entries refer to the number of blog post containing acf fields that I will have to edit.
I lost you on the third paragraph.
As part of a regular wp post, I have 2 AFC fields set up in the admin panel edit post. One is a multiple choice field the other is holding two content parts Ingredients and Instructions. They were set up this way by a developer.
I fill in the content surrounded by the shortcode and hit publish.
Then everything works fine.
However I have 850 post inclusive of AFC fields, which need be edited und re-published (updated). This doesn’t work to all I know.
But I gladly try a couple more to be sure. With other pressing client work pending, I can get back early tomorrow.
Thank you
After a more thorough test period:
Updating (editing) an AFC field is a two step process:
1) Edit the content of a field to include shortcode and update will result in the field to display your input converted to html (divs…) – code appears in preview
2) Hit update a second time and preview (including actual results) will show the desired results (BUT NOT ALL).
To demonstrate this here’s a screenshot of how the shortcode turns out when posted to the standard post field followed by one with the shortcode posted to an ACF field:
reg. blog post field:
http://dermutanderer.de/wp-content/uploads/2017/01/DMA-blog-post-field-results.jpg
ACF field:
http://dermutanderer.de/wp-content/uploads/2017/01/DMA-AFC-field-results.jpg
GRAB EACH OF THE ABOVE URLs AND PASTE THEM IN A NEW BROWSER WINDOW (OR TAB). SIDE BY SIDE.
So it’s working but takes multiple steps?
You said that a developer did this for you. My suggestion at this point would probably be to talk to the guy that built your site.
Hi, when using the shortcode is there a way to display the image list instead of a regular list?
The topic ‘AFC to work with jetpack shortcodes’ is closed to new replies.
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.