Forum Replies Created

  • 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);
  • 1) Are these taxonomy fields in a repeater?
    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 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


  • 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.

  • 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

  • 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 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( 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(
          '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 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 :


    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 ???


  • 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 ?

    $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 !!!

  • thanks Elliot, but i sometimes seen this expression with % : dates_%_date_spectacle

    does no it means all fields ?

  • Elliot please would you have an idea ?

    i also try to get all spectacle where date >= date today but i don’t know how

  • this is what i got :
    Array ( [0] => Array ( [date_event] => 05/02/2015 [location] => 12 [hours] => 20h ) )

    How can i convert location id (12) to his name please ???


  • does not work too…

    $args = array (
    ‘post_type’ => ‘spectacle’,
    ‘meta_key’ => ‘dates_0_date_spectacle’,
    ‘meta_value’ => ’05/02/2015′


    echo get_field(‘dates_0_date_spectacle’) -> 05/02/2015

Viewing 25 posts - 26 through 50 (of 64 total)

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.