0

I'm using the custom field to save some text and a few times my post didn't save. I don't know what happened. But I'm wondering if there is a size limit to that field.

var customFields = new Object();
var someValue = Request["Summary"];
customField["summary"] = someValue;
post.insertCustomField(customField);

I don't get any errors, or maybe I do but it doesn't happen every time so one guess is a size limit. Any help will be appreciated.

Also, I read somewhere that custom fields are stored as JSON strings so maybe large values are taking too much time to convert? I don't know. What do you want from me? Any help would be appreciated.

Update:
It seems that maybe there is a limit of 1MB or 2MB total applied somewhere along the way. I haven’t been able to test it since posting this question.

4
  • 1
    Custom fields, or more specifically "post meta" is stored in the postmeta table, in the meta_value column which is normally specified as LONGTEXT which amounts to a storage capacity of roughly 4 GB. Commented May 21, 2018 at 21:16
  • 1
    They are not stored as JSON strings. Commented May 21, 2018 at 21:16
  • i also have this problem now~ Thanks for your answer~ Commented Jul 11, 2022 at 9:16
  • @sunraysunray can you be more specific? The OP shared code that doesn't map on to any known WordPress functions and looks like javascript code, so it doesn't make a lot of sense. Are you sure it's the same issue?
    – Tom J Nowell
    Commented Jul 11, 2022 at 13:46

1 Answer 1

1

Is there a size limit to the value you can save in a custom field?

Not specifically, as Nathan says:

Custom fields, or more specifically "post meta" is stored in the postmeta table, in the meta_value column which is normally specified as LONGTEXT which amounts to a storage capacity of roughly 4 GB.

So it's highly unlikely you've hit a size limit. You're more likely to run into network transfer timeouts transferring data or running out of memory before you're able to hit storage capacity limits.

What's more likely is that you're using an unnamed plugin/theme/framework and having issues there that are unrelated to your question about post meta maximum size. I say this because you shared code that is not using a WordPress API written in javascript:

var customFields = new Object();
var someValue = Request["Summary"];
customField["summary"] = someValue;
post.insertCustomField(customField);

To solve your problem you should ask about it in the respective theme/plugin/frameworks support routes, but rest assured it has nothing to do with how large a post meta/custom fields value can be in the database

7
  • When I was last working on it it was part of my custom theme plugin. It was inserting or updating a post. It would work sometimes and not others. So it seemed a file size limit but network timeout could also be the issue. I’ll have to double check that. It was using php I assure you. I don’t know why I wrote the example code in JS. If I find a post that fails I’ll test against that and report back. Commented Jul 11, 2022 at 17:07
  • 1
    I would consider it a challenge just to send a 1GB request from javascript to the server nevermind send, have it received, then saved in the database. I would strongly recommend you post actual code, specifics and details are incredibly useful and making your problem generic and abstract to be helpful actually hurts your questions and severely reduces the chance of finding the solution to your problem.
    – Tom J Nowell
    Commented Jul 11, 2022 at 17:53
  • 1
    Otherwise, as my answer says, there are upper limits to post meta size, but they're far larger than anything you will ever reach. If that answers your question consider marking it as correct. Remember, I'm not trying to solve your problem, I'm trying to answer your question as it was written
    – Tom J Nowell
    Commented Jul 11, 2022 at 17:54
  • Thanks I appreciate that. The content size was between 200kb to 2MB of raw HMTL CSS JS as a single string so nowhere near that limit. When I get back to the code I’ll post the php Commented Jul 11, 2022 at 17:57
  • I'd be wary of having that ability from a security POV, a lot of WAF's and CDNs will treat that kind of request as suspicious too and block them by default
    – Tom J Nowell
    Commented Jul 11, 2022 at 21:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.