In WordPress, you cannot trust the whole core. You have two ways to change WordPress Core:
The first option: plug-in functions
Some functions may be overridden. This can be done in the functions.php file or in the plugin file. You can check out the list of Pluggable Functions .
Second option: Filter and Action hooks
- Filter hooks can be used to modify vars inside the WordPress core.
- Action hooks can be used to trigger custom functions for some events.
Note 1: you can create your own filter and action hooks in your theme or plugin.
Note 2: you can use filter hooks to trigger a function if you do not find a convenient action hook.
If you follow WordPress coding standards, you can deeply change the behavior of WordPress.
For your display function, you should look for a post_where filter to do something like this:
add_filter( 'posts_where' , 'my_posts_where' ); function my_posts_where( $where ) { global $post; if ($post->post_type == 'video_photo' ){ $where .= " AND meta_key like 'tqmcf_%'"; } return $where; }
Edit 1:. The following may be more appropriate, even if this particular request is difficult to configure.
add_filter( 'query' , 'my_meta_form_query' ); function my_meta_form_query( $query ) { $pattern = "/SELECT(?:\W*)meta_key(?:\W*)FROM (.*)(?:\W*.*?)*LIMIT(?:\W*)([0-9]*)/g"; if( preg_match($pattern, $query, $vars) ) { $postmeta = $vars[1]; $limit = $vars[2]; $query = "SELECT meta_key FROM $postmeta WHERE meta_key like 'tqmcf_%' GROUP BY meta_key HAVING meta_key NOT LIKE '\_%' ORDER BY meta_key LIMIT $limit"; } return $query; }
You need to insert the code into the code to find the suitable hooks and how best to filter the variables. In this example, we check if the request matches the method in the meta_form() function. We retrieve existing query vases and build a new query, including the WHERE . I have not tested this piece of code, and there may be some errors, but it can give you an idea of ββhow we change the main code.
source share