Yes maybe ACF could change the look of taxonomy field.
But yes also, in my case, maybe can i use the filter you tell me, can i insert html tags into ?
I wish:
FIRSTLEVEL
<padding 20px> 2nd level
<padding 20px> 2nd level
<padding 20px> 2nd level
so, imagine my CPT is MOVIE.
My custom taxonomy MOVIE GENRE = (Animation, Horror, Action…)
i have 2 Taxonomy fields i my form : Genre#1, Genre#1
Both are linked and populated with MOVIE GENRE.
I choose Animation for Genre#1 and Action for Genre#2.
I display this data in admin columns, and so i have Animation,Action in column Genre#1 and Animation,Action in column Genre#2, instead of Genre#1:Animation Genre#2:Action this is the problem !!
I know wp_set_object_terms() and do you think i have no other choice to use it ?
thanks
but they must be synced to the custom taxonomy to do searches
In my taxonomy ‘from’ i have only 2 values, ID are 68 and 69.
So update_field(‘from’, ’69’, $post_id);
should automatically set the from value isn’t ? because it does not.
Actually I have removed the taxonomy radio field because i don’t want the user can choose it. So can i directly update the taxonomy value when ACF save post ?
thanks
thanks for help
thanks, assuming i know the taxonomy ids , could it be like this ?
function my_acf_save_post_function($post_id) {
$condition = get_field('first_tax_field', $post_id, false);
// get the value checked by user
if ($condition=='36') {
update_field('second_tax_field', '78', $post_id);
}
else {
update_field('second_tax_field', '79', $post_id);
}
}
thanks i am going to try it.
this the related post
https://support.advancedcustomfields.com/forums/topic/update_field-for-taxonomy-field-type/
1) Are these taxonomy fields in a repeater?
NO
2) Is your ACF field you want to update set up to “Load Terms” and “Save Terms”?
Not sure , YES i suppose
3) Do you want to save the values in just the ACF field or do you want to Save/Add these values Terms for the post in WP?
For the POST in WP
Actually i have 2 ACF taxonomy radio fields in a form in ACF save post.
First is visible, second is hidden.
I would like to get the value (ID) of the first taxonomy field checked by user.
Depending on this value, i want to set the value of the second field and save it to the database.
i tought i had to use get_terms and wp_set_object_terms
thanks John, my action has 20 as priority. I can check after save the value or before, nevermind.
But in another post you said to use wp_set_object_terms( $post_id, $term_id, ‘name’);
isn’t ?
thanks
thanks a lot John, but is it possible to have these fields (from CPT#1) in the backend list (and in the CPT#2 form in read only) ? Using AdminColumnPro ?
Should i also use https://wordpress.org/plugins/post-2-post-for-acf/
thanks
if i understand ACF taxonomy uses SELECT2 JS library and in that allows multiple options (hierarchical, bold etc…) Possible to setup these optinos ?
Works very fine, thanks a lot !!
thanks John but could give me an example please ?
thanks, why using [url] and not this ?
$field[‘value’] = ‘https//’;
and the problem is that replace the existing content, i need that add ‘https’ only if the field is empty.
thanks
Localisation is simple text and i don’t search on it. I don’t search on time only on DATE.
i use ‘compare’ => ‘>=’, and ‘compare’ => ‘<=’, in my query
i have a CPT event.
A single event can have multiple date/time/localisation
So i use ACF repeater for each event with line: DATEPICKER / TIMEPICKER / TEXT
i am just wondering if there is a way to optimize my wpquery
thanks
hello,
I have a form1 on page1 and a form2 on page2, i need to get the value submit by the forms, no matter for me if it is after on before the post is created in database.
For now this is what i do but
1. Don’t know if it’s the good hook
2. Like in docs, i have hardcoded (field_5c33260621785) the fields to retrieve (is it no possible dynamically ?)
3. In this function, how can i know if $_POST[‘acf’] comes from FORM1 or FORM2 ?
4. THnaksss a lot !!!
function my_acf_save_post( $post_id ) {
$fields = false;
if( isset($_POST['acf']) )
{
// get taxonomy sent my form on PAGE A
$zones = $_POST['acf']['field_5c33260621785'];
foreach ($zones as $z) {
$term = get_term( $z, 'zones_de_marche' );
$name .= $term->name ."\r\n";
}
}
$args = array(
'number_to' => '+33111111',
'message' => $name
);
twl_send_sms( $args );
}
add_action('acf/save_post', 'my_acf_save_post', 20);
Sorry I don’t really understand…
I use twilio core to send sms so in acf post I use the sms function to send it.
I must retrieve all the values submited in the form and affect to the sms body variable before to execute the function. Problem is not the sms. It would be the same if It was an email.
I must get all values from $post[acf] and put them in $mybodymessage.
Doing this is the first difficulty.
The second difficulty is I don’t understand how can I now if $post[acf] contains data from my formA or my formB
Hope it helps …
Thanks
Thanks a lot
So if I understand as I have 3cpt for 3 different forms , I will have 3 « if » where I will have $post[acf]…
I am surprised that to parse the content of $post[acf] I have to specify in harcode the if of each field, I toought it could be dynamic.
I have a lot of taxonomies fields to get so many for each loop.
Ok thanks i understand, so i’ve used a wp calendar widget clone(https://pippinsplugins.com/custom-post-type-calendar-widget/) and i think
instead of using :
// Get days with posts
$dayswithposts = $wpdb->get_results( "SELECT DISTINCT DAYOFMONTH( post_date )
FROM $wpdb->posts WHERE MONTH( date ) = '$thismonth'
AND YEAR( post_date ) = '$thisyear'
AND post_type IN ( $post_types ) AND post_status = 'publish '"
, ARRAY_N );
i suppose i musts do something like :
$args = array (
'post_type' => 'post', // your custom post type
'meta_key' => 'date_de_la_manifestation', // your custom date field name
'orderby' => 'meta_value_num',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'date_de_la_manifestation',
'compare' => 'REGEXP',
'value' => '[0-9]{4}' . $thismonth . '[0-9]{2}',
),
)
);
and after make a loop on result to get the day of my acf field date_de_la_manifestation and displays it in the calendar.
Hi John,
Thanks a lot for your answer, i’m just surprised there no third party solution, because i suppose it’s a basic need, using and sorting in widget calendar with ACF date field instead of wp post_date.
Thanks
Thanks John,
What happened is that my taxonomy fields filled with all the taxonomy of the post.
For example, if i choose for TAXO FIELD1 the value “PLACE1” and for TAXO FIELD2 “PLACE2” it becomes :
TAXO FIELD1 -> “PLACE1” “PLACE2”
TAXO FIELD2 -> “PLACE1” “PLACE2”
If i uncheck value and save it stays like this.
If i uncheck LOAD TERMS it seems to work but i don’t know why ???
regards,
is it a bug with taxonomy field ??
in 5.2.6 the option was SYNC TERMS no there’re LOAD TERMS SAVE TERMS
ok thanks so would you mean this code should show
only EVENT where month=current month ?
thnaks
$today = date("d/m/Y");
$themonth=substr($today, 3,2);
$args = array (
'post_type' => 'EVENT',
'meta_key' => 'dates_%_date_EVENT',
'meta_value' => '[0-9]{4}' . $themonth . '[0-9]{2}',
'meta_compare' => 'REGEXP',
);
Man , thanks a LOTTT !!!
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.