Forums Forums Search & Filter Pro Author field not honouring Auto Count setting

Viewing 4 posts - 1 through 4 (of 4 total)
  • Anonymous
    #223139

    I have my post results limiting by a meta value ‘if meta value > current date’.
    I have a Category and Author filter fields.
    This is working fine, and results are all o.k.
    However, on the filtering display, the Author Field (as Check Boxes) doesn’t seem to be honouring the Auto Count setting (in General tab).
    It works for categories and tags – they get hidden if no results, and the counts are correct on that, however, for the Author field, all authors are always shown, with the counts in full, as if all posts are returned ignoring the restriction in the post meta.

    Is it actually supported for the Author field? I noticed it’s not mentioned in the description of the Auto Count option “Auto Count: Dynamically update the count number shown and also calculate which options to hide in your tag, category, taxonomy & post meta (choice) fields.”

    Trevor
    #223144

    The count and Auto Count does not include the Author field, as you see from the note you quote.

    For now, the only way around this is to have a custom field in the posts for Author and use that instead.

    Anonymous
    #223172

    Thanks Trevor,
    Hopefully it’ll get implemented in the future.

    For anyone else facing this problem, I ended up creating a custom field as Trevor mentioned, setting it to hidden, then using a save action to add the author name to that field. (I needed this to be automatic, I didn’t want to rely on people having to tell the system who they are when adding posts)

    Here’s code that saves Author display name to a custom field if anyones interested:

    // 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
    #223174

    Thanks for sharing. I will close this thread for now.

Viewing 4 posts - 1 through 4 (of 4 total)