Rename file after title , one small problem
Use get_the_title() since you’re already being passed a post ID. function rename_attacment( $post_ID ) { $post = get_post( $post_ID ); $file = get_attached_file( $post_ID ); $path = pathinfo( $file ); //dirname = File Path //basename = Filename.Extension //extension = Extension //filename = Filename $newfilename = get_the_title( $post_ID ); $newfile = $path[‘dirname’] . “https://wordpress.stackexchange.com/” . $newfilename … Read more