I want to remove the post status count from WordPress edit.php
.
My WordPress CMS have more than 500,000 posts. The publish count is loaded every time you open the page. The following query is fired every time.
This makes my WordPress CMS loading very slow.
SELECT post_status, COUNT( * ) AS num_posts FROM wp_posts WHERE post_type = 'post' GROUP BY post_status
By tracing the code, I’ve worked up the only solution that I can see.
The filter
bulk_post_updated_messages
is ONLY called on theedit.php
screen.The counts are not calculated (in
class-wp-posts-list-table.php
,get_views
method) if the global variable$locked_post_status
is not empty.By gluing these two pieces of information together, I’ve got a solution that you can use by dropping it into your theme’s
functions.php
file:i came up with this solution.
the post counter uses the wp-cache, the idea behind this approach is, to prefill the cache with the “correct” object containing 1’s (0 would skip the status from being clickable) – at the earliest moment.
it results in all stati being displayed – with 1’s and the query is not run et-all
in addition it returns a css snippet to hide the
(1)