Forums › Forums › Search & Filter Pro › Author field not honouring Auto Count setting
Tagged: Author Field, auto count
- This topic has 3 replies, 2 voices, and was last updated 5 years, 1 month ago by Trevor.
-
Anonymous(Private) October 8, 2019 at 3:54 pm #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.”
Anonymous(Private) October 8, 2019 at 4:57 pm #223172Thanks 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');
-
AuthorPosts