add_filter('pre_get_posts', 'customize_query');
function customize_query($query) {
if($query->is_main_query() && ($query->is_search() || $query->is_archive()) {
$query->set('update_post_meta_cache', false);
$query->set('update_post_term_cache', false);
}
}
Then wordpress will make 2 less queries for those pages & then you can use the $wpdb object to write custom queries.
Related Posts:
- Optimize WP Meta Query for large amount of post meta?
- Meta compare with date (stored as string) not working
- How metadata API works?
- WP_POSTMETA – What do these values mean inside the data structure?
- What type of index should I use for postmeta?
- How to create a meta_query to get all posts with a specific meta data?
- Compare meta_query with a Regular Expression and do a less-than operation on it
- $wpdb class updating meta_value using Ajax [closed]
- cleaning up safely wordpress wp_postmeta table
- Should I save this mulit dementional arary as one post meta?
- How to check if a post meta key/value pair already exists for a specific post
- get Insert id for meta field
- Filter posts by meta key
- Search post overlapping dates – meta_query with meta_key
- How can I query for posts using a date stored in post-meta?
- I can not display meta value in extras.php and template-tags.php
- Negative meta_query if storing multiple post_meta values with shared meta_key
- How to get posts by meta value as multi-dimensional array?
- Combine meta query and give a specific meta query a higher priority
- Is there any way to get all custom posts and all custom terms with it’s meta in few queries?
- Multiple meta key and value search in the query
- Multiple postmeta values to the same post_id/meta_key combination?
- Retrieve posts from meta key
- How to show specific meta keys of all posts in admin panel?
- How to create a link for wordpress meta datas?
- Cache metadata for set of posts
- How we insert values into database using metabox WordPress?
- Check if Post Title exists, Insert post if doesn’t, Add Incremental # to Meta if does
- How to update/insert custom field(post meta) data with wordpress REST API?
- Custom Queries: Joining On Meta Values From Two Custom Post Types
- How to update single value in multi dimensional Post Meta?
- Front-end update_post_meta snippet displays white screen?
- How to get meta value in wp_attachment_metadata
- Documentation for post meta
- Clean up output added via wp_head()
- Comparisson between date() and a date from wp_postmeta
- Displaying posts with only upcoming dates according their custom field date value
- Get post from meta_key and meta_value
- get_post_meta returns bool(false)
- How to get custom post type to display post meta on archive pages?
- WP_POSTMETA changes site crash
- meta_post_meta return value 1
- How to use post_id with a Class?
- Query metas (and not : query posts by metas)
- Set default Custom Post Meta Value
- WordPress front-end media (image) upload ERROR!
- running function during post save and adding variable to post meta
- WP_Query with meta_query for children
- how to make members list directory through wordpress post custom meta key.
- update_post_meta saves nothing in database when run in publish_post
- Can’t access post meta on new post creation (cpt)
- Custom post meta values reset by autosave [duplicate]
- Is it possible to retrieve a post and its metadata at the same time?
- Post meta as array looks like string instead of array
- Why does get_transient() always return string even if integer set?
- Author_meta ONLY if it exists
- How to test the outcome of a wpdb query?
- get_post_meta as a list for drop down search filter
- WP_Query of custom post type sorted by meta_key has unexpected results
- Is there a way to disable post meta caching for development?
- update_post_meta not working?
- Change wordpress meta tag description using WP functions
- Drag and Drop Metadata Menu Order
- Cant create or update meta fields using WordPress REST API
- Display current ranking of post as a number in post title
- delete duplicates wp_postmeta
- Post Thumbnail missing when using webp format while sharing
- Bulk Update Post Meta Values from Different Post via Rest Api
- update_post_meta() is not saving the value
- Only show meta on one post type on search results page
- How to register post meta with multi level arrays?
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- If I disable screen options, does WP still try to update post meta?
- Can we have duplicate key pair values in post meta data?
- I created a Custom Meta Box but it is not displaying the value on my post page
- Meta data being pulled from wp-login.php
- WordPress Query optimaization for slow query
- Get post content before rendering
- wp_insert_post inside save_post adds wrong metadata to inserted post
- Rename image filename using ‘media_handle_upload’
- How do I update a specific value within array in a products metadata?
- Update Post metafield of specific categories
- Using Self Hosted Video URL With Custom Fields
- get_post_meta not work in php foreach
- Why are my custom metaboxes not updating the post meta?
- How to get meta value based on latest post id with group by term name
- Problem serializing single quote and double quote into post meta
- Storing post_meta fields in array
- Performace on 1 million plus meta fields vs 1 field with 1 million multi array
- Fetching array of postmeta with $wpdb and in_array conditional
- Piklist File Upload
- Return a single custom post from multiple meta queries
- how to echo/display the custom field value in specific custom field name?
- update_post_meta() not working in bulk option
- How to update the ‘modified_time’ of a post ONLY when content is changed?
- Multiple If else statements on Search Result Page
- How to make certain content of the post noindex and no follow. not entire post?
- get_children filter with postmeta
- wordpress query making site very slow
- if condition from post_meta not working in save_post