Introduction:
WordPress is a popular content management system that empowers millions of websites and blogs. However, as your WordPress site grows and accumulates data, you may encounter performance issues that impact the speed of your site’s interface. One common problem area is the post creation process, where slow queries and unnecessary metaboxes can cause delays. In this article, we will delve into a specific slow query issue and explore a solution to remove the “Custom Fields” metabox, ultimately enhancing the speed of adding new posts or articles.
Understanding the Slow Query:
The slow query in question arises from a common task of sorting by the meta_key
column in the wpwl_postmeta
table. This sorting operation, combined with other conditions, can become a performance bottleneck, particularly when the postmeta table grows large. The slowdown may be noticeable when accessing the “Add New Post/Article” interface within the WordPress admin area.
Using the Query Monitor plugin, we can see that the below query is taking about 10 seconds. This happens on a website that has over 61.000 articles.

Analyzing the Impact of the “Custom Fields” Metabox:
The “Custom Fields” metabox, although once useful for managing additional data associated with posts, can contribute to the slowdown. This metabox relies on the slow query mentioned above, as it sorts and displays the custom fields based on the meta_key
. However, in many cases, the metabox is no longer utilized extensively, making it a prime candidate for removal.
The Solution:
Removing the “Custom Fields” Metabox: To alleviate the performance issues and enhance the speed of adding new posts or articles, we can remove the “Custom Fields” metabox from the post editor interface. By doing so, we eliminate the need for the slow query associated with sorting the meta_key
column.
Implementation Steps:
- Open the
functions.php
file of your active WordPress theme or create one if it doesn’t exist. - Add the provided code snippet, which hooks into the ‘admin_menu’ action and removes the “Custom Fields” metabox from all post types.
- Save the changes to the
functions.php
file.
The below code is inspired from : https://9seeds.com/wordpress-admin-post-editor-performance, the solution #3.
/**
* Remove Custom Fields metabox from post editor
* because it uses a very slow query meta_key sort query
* so on sites with large postmeta tables it is super slow
*/
function remove_post_custom_fields_metabox() {
$post_types = get_post_types(['public' => true], 'names');
foreach ($post_types as $post_type) {
remove_meta_box('postcustom', $post_type, 'normal');
}
}
add_action('admin_menu', 'remove_post_custom_fields_metabox');
Code details:
The remove_post_custom_fields_metabox() function is designed to remove the "Custom Fields" metabox from the post editor interface in WordPress. By removing this metabox, unnecessary queries and processing associated with displaying and sorting custom fields are avoided, resulting in improved performance when adding or editing posts.
The function begins by retrieving an array of publicly accessible post types using the get_post_types() function. This ensures that only relevant post types are considered for removing the metabox.
Next, a loop iterates through each post type, and the remove_meta_box() function is called with the parameters 'postcustom', $post_type, and 'normal'. This removes the "Custom Fields" metabox from the specified post type and interface context.
Finally, the function is hooked into the 'admin_menu' action using the add_action() function. This ensures that the remove_post_custom_fields_metabox() function is executed when the WordPress admin menu is being initialized.
Results and Benefits:
After implementing the solution, you will notice an improvement in the speed and responsiveness of the “Add New Post/Article” interface. By removing the unnecessary “Custom Fields” metabox, you eliminate the slow query that hampers performance, allowing you to focus on creating content efficiently.
In my case, this decreased the total loading time of the page from 15 seconds to 4 seconds. I am also using Redis Object Cache and WP Fastest Cache.
Additional Performance Optimization Considerations:
While removing the “Custom Fields” metabox helps alleviate one specific performance issue, there are other aspects to consider when optimizing WordPress performance. Some factors to explore include:
- Caching mechanisms: Utilize caching plugins or server-level caching to store and serve static versions of your site’s content, reducing the load on the database and speeding up page rendering.
- Database optimization: Regularly optimize and clean up your WordPress database by removing unnecessary data, optimizing tables, and running database maintenance routines.
- Plugin analysis: Assess the impact of installed plugins on performance. Disable or remove unnecessary or resource-intensive plugins that may slow down your site.
- Server configuration: Ensure that your server has sufficient resources to handle the traffic and workload of your site. Consider upgrading to a more robust hosting environment if necessary.
Conclusion:
By addressing the slow query issue and removing the “Custom Fields” metabox, you can significantly enhance the speed and efficiency of the WordPress interface when adding new posts or articles. This optimization allows you to focus on content creation rather than dealing with performance bottlenecks. Remember to consider additional performance optimization techniques to ensure a smooth and fast experience for both content creators and visitors to your WordPress site.