• hampsterj

    (@hampsterj)


    i’m trying to automate when i upload say an audio file the name of my post is set the the name of the file i’m uploading and set a download name could any one point me on a path to start this

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    One approach is to hook the ‘wp_insert_post_data’ filter. First ensure the filter fired for a post post_type and not an attachment. If so, then get the upload filename from the post’s attachment and alter the post title in the passed data array. I think the attachment already exists at this point, but if not, the filename can be saved somewhere from the ‘wp_handle_upload’ filter for use when the post is inserted.

    Doing it this way does mean the correct title is not displayed in the post edit screen, whatever the user enters is discarded without warning. It’s possible but more involved to have the edit screen reflect the filename.

Viewing 1 replies (of 1 total)
  • The topic ‘automate help’ is closed to new replies.