Seems like you can’t use a shortcode as a value inside a VC element, you can only use it inside textarea.
Also from what I understand this plugin just enhances the already existing functionality of ACF inside VC, it just allows you to render google maps for instance and others custom ACF fields, nothing besides that.
It’s a pity as I was expected to be used in the way you try to use it.
@maximdesign,
I created this filter in order to archive my needs:
add_filter(‘the_content’, ‘apply_acf_shortcodes_to_content’);
function apply_acf_shortcodes_to_content ($content) {
// Check if “{
acf” appears in text
if (false !== strpos($content, ‘{
acf’)) {
// Find converted ACF shortcodes and bring them back to normal
preg_match_all(‘/{[^{]*acf[^}]*}
/i’, $content, $matches);
// Set to current
$evaluated = $matches = current($matches);
// Loop through matched shortcodes
foreach ($evaluated as &$value) {
$value = do_shortcode(str_replace(
array (‘{
‘, ‘}
‘, ‘
‘),
array ( ‘[‘, ‘]’, ‘”‘),
$value
));
}
// Replace matched with values
$content = str_replace( $matches, $evaluated, $content );
}
return do_shortcode($content);
}
Put it inside your theme’s functions.php file
-
This reply was modified 8 years, 5 months ago by
panosru.
you can find the code here: http://pastebin.com/46y2VYRk
I haven’t tested it from performance perspective
-
This reply was modified 8 years, 5 months ago by
panosru.
Update to the regexp due to an issue: http://pastebin.com/v3k5KNyW
Hello @panosru,
thanks for your help.
Unfortunately, it doesn’t seem to work: it continues to display the shortcode as a class, instead the value.
@maximdesign,
strange as I use it for me and it works like a charm, I actually extended it a bit more to work with repeater field and integrated it with vc and templatera, take a look at the code here: https://gist.github.com/panosru/f2d3d6f5008958ae81b71510800be108
HI guys, Let me understand this correctly. You want to put a custom field value into a field in an VC element – in this case our plugin, and the class field ?
So we would have to render any afc shorcode in that field ?
Hi,
I’m trying to explain what we want achieve.
Each post has a custom field, let’s say “color”.
Then, there is the VC grid builder.
In particular, there is a field for the class.
We want to render the custom class associated in the post.
I’m actually using this code: https://gist.github.com/panosru/f2d3d6f5008958ae81b71510800be108 in order to use acf values inside VC elements and templatera, @dejliglama in case you find any use of the code feel free to use it
Thanks @panosru we will look into that!
Hi @maximdesign – The shortcode inside the VC element field wont work. It’s a shortcode inside a shortcode, which we do not handle at this time. Not even sure it’s something we can handle without also having VC to handle it. Since all of VC is basically shortcodes.
@panosru could you give me a hint what to do with your code, please?
-
This reply was modified 8 years, 1 month ago by
wwwland.