WordPress and MySQL: how to transfer Meta_key and Meta_Value from one post_id to another
UPDATE wp_postmeta SET post_id = 6219 WHERE post_id = 4319
UPDATE wp_postmeta SET post_id = 6219 WHERE post_id = 4319
To modify an RSS item’s <link> node value, use the the_permalink_rss filter. This is demonstrated in the code below where if a feature post has a value set for _featureurl, we will return the custom value. Otherwise, the default permalink is returned: /** * Filters the permalink to the post for use in feeds. * … Read more
For some reason, you have to double the arrays, maybe this doesn’t affect you as you are referencing the firt element. I use this in PHP: function saveMetaItem($id_order,$id_item,$id_product,$meta_key,$meta_value){ $woo = new wooclient(); $data = array( ‘line_items’ => array(array( ‘id’ => $id_item, ‘product_id’ => $id_product, ‘meta_data’ => array(array( ‘key’ => $meta_key, ‘value’ => $meta_value )) )) … Read more
Try this code: function cf_description_to_content($post_ID){ $data = get_post_meta( $post_ID, ‘wiloke_listgo_my_custom_fields’, true ); // Put whatver description you want assign to the description field $data[‘description’] = $_POST[‘wiloke_listgo_my_custom_fields’]; update_post_meta( $post_ID, ‘wiloke_listgo_my_custom_fields’, $data ); } add_action(‘save_post’, ‘cf_description_to_content’, 100, 1);
If I am understanding your question correctly, you have a post meta which will return you your vehicle type and based on this you wish to create something like: $vehicle_type – My $vehicle type If you are not venturing into categorization of vehicle after vehicle type then the below mentioned code should work fine. foreach … Read more
Before saving your meta data, you have if ( ! current_user_can( ” ) ) return I’ve never run current_user_can against and empty string of capabilities, so I’m not sure what your results are going to be, but it’s very possible this returns a false, and you return at this point. Also, be sure you sanitize … Read more
get_post_custom() is a very outdated method of getting post meta. To get the post meta properly you should use get_post_meta(): $my_custom_field = get_post_meta( get_the_ID(), ‘_gardener_address’, true ); foreach ( $my_custom_field as $key => $value ) { echo “<li>” . $key . ” => ” . $value . “</li>”; }
I gave your code a look over, and updated it to include proper escaping and sanitation. I suspect that the problem could have stemmed from the lack of escaping. I also applied some formatting and WP best practices, but otherwise the code is the same. /** * Meta box display callback. * * @param WP_Post … Read more
OK, so you’re almost there. Let’s say you have this query: $argsLoop = array( ‘post_type’ => ‘cars’, ‘posts_per_page’ => 12, ‘paged’ => 1, ‘meta_key’ => ‘cars_price’, ‘orderby’ => ‘cars_price’, ‘order’ => ‘DESC’ ); $cars = new WP_Query( $argsLoop ); // All you have to add is this line: shuffle( $cars->posts ); Now you can do … Read more
You’ll have to use different function for that. wp_get_attachment_url returns a full URI for an attachment file and it doesn’t know what type of attachment it is. It makes no sense to generate thumbnail for .zip od .txt files, so this function doesn’t allow you to get thumbnail url. On the other hand, wp_get_attachment_image_url knows … Read more