I think you’ll need to add a posts_join filter, to join the posts and postmeta tables.
This link should be helpful: http://codex.wordpress.org/Custom_Queries, in particular this piece of example code:
add_filter('posts_join', 'geotag_search_join' );
add_filter('posts_where', 'geotag_search_where' );
function geotag_search_join( $join )
{
global $geotag_table, $wpdb;
if( is_search() ) {
$join .= " LEFT JOIN $geotag_table ON " .
$wpdb->posts . ".ID = " . $geotag_table .
".geotag_post_id ";
}
return $join;
}
function geotag_search_where( $where )
{
if( is_search() ) {
$where = preg_replace(
"/\(\s*post_title\s+LIKE\s*(\'[^\']+\')\s*\)/",
"(post_title LIKE $1) OR (geotag_city LIKE $1) OR (geotag_state LIKE $1) OR (geotag_country LIKE $1)", $where );
}
return $where;
}
Related Posts:
- Remove post from latest posts after a month only with certain tag
- Add options to featured image
- mysql custom wp query
- Change meta tags programatically
- Use a function to update post meta based on other post meta
- update_post_meta for custom field not working upon form submission
- WordPress – thumbnail image from youtube (function and loop)
- Assign category using custom field?
- Convert User ID’s to User Names in a single.php file
- Can’t check if a post has thumbnail adding filter to get_post_metadata()
- Move Post to different category if post_meta field is 0 or is 2 days old?
- What WordPress function to use to get meta value by using meta keys?
- show first 3 thumbnails of posts in different sizes [closed]
- Default Custom Field Value Automatically Update
- Post meta not updating
- Function to update post_meta based on existing post_meta
- How to obtain the recent posts without their content in an efficient way?
- Prevent custom field from being updated after first publish
- Get array of metakey in all posts
- User function to return multiple get_post_meta()
- What are the meta fields for an attachment?
- Using functions.php to include code that’s processed inline
- Getting images from media library and get_the_date() not working
- How to avoid saving empty data to sql while using add_meta_box
- How to change text color depending on the number value (Using javascript)
- How to add custom metakey to shop_order page’s searching function?
- Update wp_postmeta table based on 2 keys
- blank page with wp_get_attachment
- Reference multiple style sheets, clearing styles for permalink page, custom fields for css
- How To Display Author Popup on Entry Meta (Genesis Framework)?
- Creating a “Related Meta” type field?
- save_post doesn’t correctly process function call with php class
- Pagination not working on my archive page for a custom post type
- Return ACF Field value function
- update_post_meta not working in function
- How To Get WordPress Categories Last Update Date?
- How to add a meta information to the URL?
- Automatically add custom fields (post_meta) to all published posts, hourly, via wp_cron?
- update_post_meta after form is submited
- Add custom fields after post/page title
- Display post_meta-by_key on product catalogue
- Integrating custom API for post content into Admin interface & Public Website [closed]
- How to save custom made object in an array in a post meta field
- Adding and updating repeating custom field meta data
- Missing feature image link function
- How to customize the_archive_title()?
- Get menu object from theme_location
- Displaying the number of updates available in the Admin area
- Trying to use add_action and do_action with parameters
- Safe to disable wptexturize?
- Targeting specific menu with wp_nav_menu_items
- Insert Ad Code in the Middle of a Post
- disable comments if array exists
- WordPress Change Post Templates,but not drop down, but Image selection
- Programmatically Add Font-Awesome Icons to Category Widget
- Remove images from get_the_excerpt
- Remove “says” from comments
- Reuse variable in hook callback
- Can you use admin pages functionality on the frontend of your site
- Display more recent and less recent posts in same category
- Overwrite Parent Theme add_image_size in Child Theme
- Custom registration URL lost when user makes signup mistake
- Individually styling date month year [closed]
- Tiny MCE-modifications (plugins) stopped working in WordPress 5.6
- Writing functions in WordPress functions.php that don’t replace a WordPress core function
- HTTP_HOST changing in functions.php
- Change position of media in admin menu
- Getting custom image size URL in functions
- new_excerpt_more link not working properly
- WordPress function saves a post twice and updates all posts
- Change CSS for logged in users
- if statement for wordpress default featured image on single post
- How to change this simple code so that it sends the email notification after payment in WooCommerce?
- Add code to Functions.php
- How can we know we are not in edit page
- Adding jQuery datepicker to Custom Post Type Metabox [closed]
- Allowed memory size of 33554432 bytes exhausted (tried to allocate 9967617 bytes) in …\wp-includes\functions.php
- What happens to the text in functions.php file outside of the php enclosure?
- wordpress acts like functions.php doesn’t exist [closed]
- retrieves menu and converts it to a readable array
- WordPress can’t get jquery/unslider to work
- template_redirect action only firing if logged in
- Unable to use get_page_by_title() more than once per page?
- Featured Image and Tags problem
- Advanced method to control cache of enqueued style/script
- large image size of 1440×1440 not pulling 2x of 2880×2880 image
- How to make the RTL.css the dominant css code?
- I’m getting invalid taxonomy in init action
- Only seems to be displaying one child when there are supposed to be multiple
- Rest API User Levels
- adding google analytics via echo or between tags
- Slider Thumbnail Size Issue [closed]
- WordPress permanently logging users out
- Meta Box value not been pulled in
- How to Update User Meta Field other than from profile?
- Retrieve array of attachment IDs attached to a given Post ID
- More link – not text
- wp trim function not working
- PHP Notice: Function is_page was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false
- How do i set global variable in a function in wordpress functions.php