Support Forums

Hey there, it looks like you've been redirected from designsandcode.com - as you can see we have a new home - read more

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Datefilter

Viewing 10 posts - 11 through 20 (of 32 total)
  • Trevor Moderator
    #238589

    A coder (such coding is outside the scope of our technical support, but it can be done) could automate the filling of this newly required field, but that would only work as you edit/save a post.

    introma
    #238592

    So what should I do?

    Trevor Moderator
    #238596

    We can, together, explore going down that route. The first thing I think you CAN do, is to create the ACF field. I would suggest making a dropdown field, where you specify the choices. Open ONE post and manually set the value (correctly), and then we can add that to the form.

    Then we can see if we can code it together.

    BTW, are you using a child theme?

    introma
    #238598

    Thank you for your help.
    OK. Let’s do it like this.
    Yes I am using a child theme.

    Trevor Moderator
    #238600
    This reply has been marked as private.
    introma
    #238602

    what would the field do? to name it in a suitable name

    Trevor Moderator
    #238604
    This reply has been marked as private.
    introma
    #238607
    This reply has been marked as private.
    Trevor Moderator
    #238609

    I found a post that will help us:

    https://support.searchandfilter.com/forums/topic/author-field-not-honouring-auto-count-setting/#post-223172

    The code used there was this:

    // save Author to author 
    function event_author_on_save( $post_id ) {
      $post_type = 'event'; //custom post type - change to post if you're just working with posts
    
      //Check if we are saving correct post type
      if( get_post_type( $post_id ) != $post_type)
        return;
    
      //Check it's not an auto save routine
      if( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) 
        return;
      
      // get the author ID of the post
      $author_id = get_post_field ('post_author', $post_id);
      // get the display name of that author
      $author = get_the_author_meta( 'display_name' , $author_id );
    
      // update the custom field value 
      update_field( 'acf_event_author', $author, $post_id );
    }
    add_action('save_post', 'event_author_on_save');
    Trevor Moderator
    #238611

    Which event did you (also) edit, or did you not edit any yet?

Viewing 10 posts - 11 through 20 (of 32 total)

You must be logged in to reply to this topic.