Is it possible to customize meta query in this way?
Is it possible to customize meta query in this way?
Is it possible to customize meta query in this way?
It would appear simply un-serialising works: $results = $wpdb->get_results( $sql_str ); foreach($results as &$result) { $result-> my_custom_meta_values = unserialize($result-> my_custom_meta_values); } If anyone can suggest a more efficient way to do this, I’d be interested.
acf/save_post affecting WP_Query results
Could you use “count” ? $cars=array(“Ford”,”Chevy”,”BMW”); echo count($cars); The above would give a count of “3” So in your code, count the number in the query array and IF greater than “X” then return the query.
Use the attribute value to decide today and tomorrow like: Code explanation: Instead of today and tomorrow naming in shortcode, I’m using show_for in this answer. Based on show_for value we can update the meta query later on. In the code, I checked if show_for is set by user or it exists in the $atts … Read more
Your SQL query is invalid regarding the WP database structure. wp_postmeta table has two columns that will help you here. meta_key : the name of your meta (post_lang in your case) meta_value : the value of your meta (en, es, …) Your SQL query should look like this instead. What changed is that you need … Read more
Your function is called “replace_thumbnail” so I am assuming you are trying to set/replace the post thumbnail (featured image): function replace_thumbnail($id) { $image_ids = array(); $media = get_attached_media( ‘image’, $id );; foreach($media as $item) { $image_ids[] = $item->ID; } // insert your featured image if (!empty($image_ids[1])) { update_post_meta( $id, ‘_thumbnail_id’, $image_ids[1] ); } // $image_ids_str … Read more
How do I subquery with custom meta fields?
Set your system up like this: locations – CPT administrative – hierarchical taxonomy natural – hierarchical taxonomy type – non-hierarchical taxonomy In the administrative taxonomy, you would create your tree: countries on the first level, regions second, departments and so on. Then, you would assign your locations to the smallest administrative denominations among your taxonomies … Read more
If it’s not too much of work, you could switch from using meta data to custom (private) terms for tagging the tickets to agents. So when ever an agent (user) is created, you would have custom function run that executes wp_insert_term to create an agent-term, where the newly created user ID is used as the … Read more