We really need a possibility to customize the output of dynamic tags more.
Example one:
I use: " Sprache: {post_terms_pa_sprache}" for displaying the languages a product is available in (Woocommerce). This leads that the languages are links automatically, but I need to deactivate these links, so only the name is printed.
Second example:
It also holds true for ACF fields. I was trying to add a custom attribute, which should return an ACF field value.
Name => artist || Value => {acf_ausstellung_to_artist}
The idea is to be able to use it for filtering e.g. via Isotope.
The issue now is that I cannot control the output whatsoever. I need that only the name of the field is rendered in the attribute,
But on the frontend it outputs the following:
âartist=âRudi Freyââ
We really need a possibility to customize that output.
E.g. be able to type {acf_ausstellung_to_artist:name} => which only outputs the name etc.
Thanks for your answer.
That would mean that I need to write a custom function for every field I want to output. Or do I miss something there?
It would be helpful to make the dynamic data filters work with acf fields as well and add a :name and :value filter option.
Yes I understand what you want to have and probably itâs a good idea to have it more integrated (also with MetaBox of course ). Maybe you can add it to the idea board as I think it wonât have that high priority because of the function callback option we already have there.
You wouldnât need to create a function for every field. What you need to do is create a function which takes the field-id as parameter (since Iâm a metabox user i donât now the exact function names of ACF you probably have to look up which function is responsible for returning the value), it could look like this:
function get_ACF_fieldValue($fieldname)
// I think it's called get_field in ACF to retrieve the field, but probably you need to use another function
return get_field($fieldName)
}
in bricks you could then use
{echo :get_ACF_fieldValue('YOURFIELDID')}
That should work as a global function and you donât need to write a function for each field!
Thanks for your suggestion.
I have tried:
{echo: get_ACF_fieldValue(âausstellung_to_artistâ)}
<?php
function get_ACF_fieldValue($fieldname){
// I think it's called get_field in ACF to retrieve the field, but probably you need to use another function
return get_field($fieldname);
}
And it generates a critical error. Think have to play around more
Hello, thanks for your help!
It sadly ignores the filter and output: "artist="<a href="https://staging.fotohof.org/?kuenstlerinnen=rudi-frey" aria-label="Read more about Rudi Frey">Rudi Frey</a>""
Oh yeah sorry it was not ment to be used directly.
I hardly know anything about ACF and Iâm not even sure if that get_field() function exists or if its called slightly different. You would have to look in their docs.
No problem Was just trying if we would be lucky. The get_field function is the right one, but I guess it cannot be used so easily. Could also be as this field is a relationship field, that it be used somehow within the loop. Sadly I am not that advanced in coding yet.
If i know hardly anything about ACF I donât know anything about relationships in ACF ⊠But what you could try to do is to navigate on that page where you want to use that dynamic data and kind of debug it inside a code-elemnt of bricks.
first code to test is
echo get_field('YOURFIELDI');
if that outputs something you can try to output the function like so:
function get_ACF_fieldValue($fieldname){
return get_field($fieldname);
}
echo get_ACF_fieldValue('YOURFIELDID');
if that also works then the only thing that could be wrong in using it with dynamic data is that you placed the function at the wrong place. I would recommend you to use the child-theme or a plugin like WPCodeBox, Code-Snippets and so on.
Coool stuff â thatâs what I ment with "I donât know too much about ACF, probably your field-type requires a loop, canât imagine that a single text field would also need a loop!)
Iâve adapted your snippet to make it more dynamically. Now you could use {echo: get_artist_list_for_attribute('FIELDID')} to reuse that function on every field of the same type!