The Relevanssi error “Could not save the file content to the custom field” means that Relevanssi has managed to read the attachment contents but cannot save them to the
_relevanssi_pdf_content custom field Relevanssi uses to store the attachment contents. Relevanssi uses the update_post_meta() function to save the content, and for some reason, that function is not accepting the custom field data.
In these cases, the first thing to check is the database collation for the
meta_value field in the
wp_postmeta database table. The document may contain characters your database table cannot accept. Before WordPress 4.2, the default collation for the databases used
utf8 characters. Since 4.2, the collations have used
utf8mb4 characters. It’s not unusual that PDF files contain characters that WordPress cannot save in a database table with a
To fix this, you need to change the database collation. You can make this change if you have direct access to the database with phpMyAdmin, Adminer or some other tool. If you don’t know anything about databases or don’t have access to the database tables, you need to ask someone else to do this for you.
Here’s what the
wp_postmeta table may look like in Adminer:
The collation is the “Options” column. Here the table uses the
utf8_general_ci collation, which is a
utf8 collation and needs to be changed. Change the collation to a matching
utf8mb4 collation, which in this case is
utf8mb4_general_ci and save the database table:
The collation of the
meta_key field does not matter.