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

Viewing 3 posts - 1 through 3 (of 3 total)
  • 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 3 posts - 1 through 3 (of 3 total)