-
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,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.
