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, 10 months ago by
Trevor.
Viewing 3 posts - 1 through 3 (of 3 total)
-
Anonymous(Private) October 8, 2019 at 4:57 pm #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');
-
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)