This doesn’t seem especially complex, but does seem bulky and prone to errors.
As I answered couple of times on similar issues – if this isn’t time critical then wait for WP 3.1 because it will have major improvements for querying by custom fields.
See Advanced Metadata Queries for brief writeup on upcoming improvements.
For sanitizing queries see $wpdb->prepare()
method – Protect Queries Against SQL Injection Attacks.
Related Posts:
- importing data from non-wordpress mysql db
- Query meta field using between
- Move value of one custom field to another
- Get multiple custom field values in a $wpdb query [duplicate]
- Difference between ‘LIKE’ and ‘IN’ in meta queries
- little help with a mySQL query to wp database
- Importing users to Buddypress with custom fields
- MySQL query to set wp_postmeta using term_taxonomy_id value
- MySQL Query that looks for post with Custom Field, then changes Category
- Unique Post Meta Values
- Add custom field to all posts in specific post_type
- UPDATE on SELECT results. A SQL query to swap Author with Meta Box value
- Importing WordPress Posts With Custom Meta Data As CSV Files Through PHPMyAdmin
- Inserting data into MagicFields using mysql queries
- Copy price categories to custom field
- If I update WordPress my custom data will be deleted from the wp_users table?
- Update post meta data (custom field) by post link
- Help setting up a sql query
- wpdb function insert doesn’t work
- How to improve my non-unique metadata MySQL entries?
- Delete a custom field in mysql for all posts with specific category id
- use mysql to replace one custom field value with another custom field value
- Copy url from post_content to custom field
- Convert many posts from having a specific meta_key to use a post_format
- Can running a WP-Cron to update_post_meta cause performance issues?
- How to add a custom field in the advanced menu properties?
- Sortable Custom Columns in User Panel (users.php)?
- How to rename a custom field?
- Adding Custom Field to Taxonomy Input :Panel
- How to activate “custom fields” section in WP3
- How to filter or search the posts using postmeta tables custom meta fields with wordpress REST API
- Add meta data to the menu
- Custom bulk action for media gallery items
- Copy SEO Meta Desc “Custom Field” to Excerpt field?
- Custom fields won’t display on my blog page
- Order Custom post type loop by custom field (datepicker)
- Localized Date Format for Custom Field
- Check if the value of a field has changed on save_post
- How to edit multiple post with Custom fields
- Undefined index error when saving content on metabox
- Saving custom image meta fields
- How to update custom user meta field in wp?
- Query post order by post and desc not working
- If category then echo a custom fields
- How can I show custom fields in the loop only to specific user roles?
- Add conditional custom option to ‘Display name publicly as’ dropdown
- Custom fields not getting saved in the databse when added to the add new user profile page
- Show 1 post and after a specific date show the next one
- How to order posts by one custom field and filter them by another one?
- Can we create a WordPress read-only virtual field derived from three other fields?
- How to create a gallery custom field for WordPress post?
- How to display image inside container of custom made widget
- Duplicate (or more) custom fields on many posts. Is there an easy way to clean them up?
- How to add new field to the account address?
- Split the_title
- Sort WP_Query with numeric custom field
- Display Multiple Values of Same Key
- How to Wrote Simple Calculations by Using Custom Fields in Loop?
- How can I use custom properties to set different background on different pages?
- Loop through incrementing custom fields
- tax query between operator like
- The conditional logic only works to show or hide?
- How to query for posts with either one or another custom field
- How show post only from after custom date
- How to sort post listing on a page using custom field value?
- Odd functions.php issue in WordPress
- Filter or order based on custom field
- ACF multi taxonomy on filterable gallery
- How to use ACF with javascript to update custom field values?
- Unable to change checkout placeholder text
- Store comment form custom field in custom database
- Custom Fields Not Showing (ACF not installed)
- How do I update custom field post meta in frontend post template?
- Sorting post by custom fileds date
- Query multiple meta values at the same time :
- How to Find List of Available Custom Fields for Theme?
- get wordpress post loop by meta box date
- Sort posts by custom fields with empty values
- Sub Field of File Field
- ACF plugin and field update
- Add custom field to post with some part of url as value
- Adding custom fields to images
- How to save dynamically generated value in post type?
- My meta boxes update wp_postmeta of posts but not of pages. What is wrong with the code?
- how to show this part only in the single post page?
- same custom field for single posts
- Import data from arbitrary CSV to WPAlchemy meta fields
- Post thumbnail size for custom field only
- Display meta data from a custom field within plugin Category Grid View Gallery
- Checking if field is set before comparing with meta_query in query_posts?
- Calling a custom profile field only it it exists
- Insert shortcode before and after a list automatically
- Only show content slideshow if “slideshow” custom field exists
- If post custom meta data is not set, show normal state
- Sort posts after filtering them through multiple taxonomies
- Media Custom Fields – get a value with PHP
- How to add google map to custom field
- jaredatch metaboxes on video post formats
- Truncating characters in Advanced Custom Fields works some places but not others?
- How to add an ACF only for parent term?