-
AuthorPosts
-
February 23, 2026 at 6:35 am #1495358
Jason Bolger
GuestHi team,
Today I found that Enfold writes empty postmeta to the DB when the layout settings are left as defaults; on a large site this creates a big problem, but it is easily fixed in core.
The following snippet will filter these out via functions.php
`/**
* Prevent Enfold from saving empty/default postmeta values
* This reduces database bloat by not storing values that match defaults
*/
add_action( ‘avia_save_post_meta_box’, ‘prevent_empty_enfold_postmeta’, 5 );function prevent_empty_enfold_postmeta( $post ) {
// Meta keys that should not be saved when empty/default
$skip_empty_meta = array(
‘footer’,
‘footer_behavior’,
‘header_title_bar’,
‘header_transparency’,
‘layout’,
‘sidebar’
);foreach ( $skip_empty_meta as $meta_key ) {
// If the value is empty, unset it from POST so it won’t be saved
if ( isset( $_POST[ $meta_key ] ) && $_POST[ $meta_key ] === ” ) {
unset( $_POST[ $meta_key ] );
// Also delete any existing meta with this key
delete_post_meta( $post->ID, $meta_key );
}
}
}`Would you consider fixing this in core?
February 24, 2026 at 5:58 am #1495406Hey Jason Bolger,
Thank you for the inquiry.
These post meta information is used by the theme and WordPress for page configuration and layout behavior, including elements like the header, footer and sidebar. Removing it is not recommended, as it may break theme or layout functionality. In terms of performance, post meta queries are generally lightweight because they are retrieved only when required and are not normally loaded all at once during page rendering. This would only become a problem if a single post or page contained thousands of meta entries, which is not the case.
Best regards,
IsmaelFebruary 24, 2026 at 11:01 am #1495417Hi Ismael,
Perhaps you misread my post, and also the hidden content (please read it and get back to me – I am trying to contribute).
Enfold is writing *multiple* empty postmeta for *every* post – even when the value is empty. The routine simply needs to be updated to check whether the $_POST[] value is empty rather than just present (and empty) before saving.
On a large site the wp_postmeta table is a big bottleneck, even with caching etc. My wp_postmeta table has over 6m entries and is the biggest table in my instance – adding unnecessary entries to it does impact performance, as the table (and indexes) need to be queried to find those records…
Cheers,
JasonFebruary 25, 2026 at 6:04 am #1495466 -
AuthorPosts
- You must be logged in to reply to this topic.
