How to hide meta from search result only on pages?
You can use this inside the WordPress loop: if (get_post_type() == ‘post’) { // do something }
You can use this inside the WordPress loop: if (get_post_type() == ‘post’) { // do something }
Look at the documentation, $wpdb->delete() takes at least two parameters, the table name and the Where-conditions as an array(). LIKE isn’t supported for delete imho, so you’ll need to use ->query global $wpdb; $wpdb->query( “DELETE FROM $wpdb->postmeta WHERE meta_key LIKE ‘_cb_%'” ); $wpdb->query( “DELETE FROM $wpdb->posts WHERE post_type LIKE ‘webcam'” ); I assume the double … Read more
when you use add_post_meta with the argument $unique = TRUE and the meta already exist, the value is not changed https://codex.wordpress.org/Function_Reference/add_post_meta If you want to update a meta, use update_post_meta update_post_meta($post_id, ‘wpcf-branch-order’, $branch);
Save, update, get and sanitize post meta as HTML not plain
Literally seconds after updating this post I found the solution….again, Must have looked at this previously and not entered the details correctly as I tried this one before. 🙂 add_action(‘pre_get_posts’, ‘add_special_sort’, 11, 1); function add_special_sort($query){ // Bail if not the main “hidden” query, as opposed to a ‘new WP_Query()’ call if(!$query->is_main_query()) return; $query->set(‘meta_query’, array( ‘relation’ … Read more
Custom Meta Fields that are Echo’d are removed on post update?
Linking posts together with Advanced Custom Fields “both ways”
Re-pointing images to cloud storage
Turns out it was an issue with not providing a geocode API! I needed to change $geocode=file_get_contents(‘https://maps.google.com/maps/api/geocode/json?address=”.$prepAddr.”&sensor=false’); to $geocode = file_get_contents(‘https://maps.google.com/maps/api/geocode/json?address=”.$prepAddr.”&key=’.$api_key); In other words, there needs to be the key parameter with the API key in that URL. I also removed the sensor parameter, as that does not appear to be needed.
You can use the $posted parameter to get the right value in your function. add_action(‘woocommerce_checkout_update_order_meta’,function( $order_id, $posted ) { $order = wc_get_order( $order_id ); $order->update_meta_data( ‘recipient_email’, $posted[‘recipient_email’] ); $order->save(); } , 10, 2); Verify that $posted is an array not an object with a var_dump on $posted. if it’s an object replace $posted[‘recipient_email’] with $posted->recipient_email … Read more