Title: replacing core un-pluggable function
Last modified: August 21, 2016

---

# replacing core un-pluggable function

 *  [meschiany](https://wordpress.org/support/users/meschiany/)
 * (@meschiany)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/replacing-core-un-pluggable-function/)
 * hello,
    I have about 3 million rows in postmeta and 60 thousands rows in posts.
 * when i checked for slow queries mysql, i notice that the core function meta_form()
   in wp-admin/include/template.php is taking about 6-7 seconds.
 * Original query:
    SELECT meta_key FROM wp_postmeta GROUP BY meta_key HAVING meta_key
   NOT LIKE ‘\_%’ ORDER BY meta_key LIMIT 30;
 * I did some digging and I found a nice query to replace it:
    SELECT DISTINCT meta_key
   FROM wp_postmeta WHERE meta_key NOT BETWEEN ‘_’ AND ‘_z’ HAVING meta_key NOT 
   LIKE ‘\_%’;
 * how can i do it in my theme or somewhere without changing the core?
    (no hook
   is available for that… as for i know…) thanks

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [xennex81](https://wordpress.org/support/users/xennex81/)
 * (@xennex81)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/replacing-core-un-pluggable-function/#post-4878945)
 * Even if you can replace the function by redefining it somewhere (not sure if 
   that is possible) you will need to reapply your ‘patch’ after every update (that
   might change that function).
 * So I don’t see why you shouldn’t modify that file. Just keep a history of all
   the changes you make to core files (if that’s important to you) and you’ll be
   able to reapply those patches after WordPress upgrades.
 * Right?
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/replacing-core-un-pluggable-function/#post-4878956)
 * No, you cannot redefine PHP functions. It is possible to directly edit the function
   declaration, but a bad idea.
 * The only clean solution I see is to define your own metabox that calls your own
   function that contains the improved query string. Enable this metabox and disable
   the default custom fields box.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘replacing core un-pluggable function’ is closed to new replies.

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)
 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)
 * [query](https://wordpress.org/support/topic-tag/query/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 3 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/replacing-core-un-pluggable-function/#post-4878956)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
