• sebastiaankop

    (@sebastiaankop)


    Hi all,

    I have written a plugin that reads metadata from image files.

    I am using a part of the metadata to rename the file and url.

    The name in the database does not change.

    How can i tell the plugin to also rename the filename in the database?

    Many thanks,

    Sebastiaan.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The filename likely exists in several locations. Typically there is an attachment post type related to the image. You would need to locate this post and use something like wp_update_post(). There will the also be at least one entry in post meta with the filename. You will need to poke around with phpMyAdmin to identify the proper key, using the attachment’s post ID as part of your search. Once you figure it out, it will be used consistently. Update post meta with update_post_meta().

    If the nature of your image uploads is different, poke around in the DB again to figure out what needs to be changed. You can use the global $wpdb object to make SQL queries to alter any DB data as needed.

Viewing 1 replies (of 1 total)
  • The topic ‘Write new filename to database’ is closed to new replies.