delete blank space in post_meta empty [closed]
do you want this: <?php global $wp_query; $postid = $wp_query->post->ID; $meta = get_post_meta($postid, ‘direccion’, true); if(!empty($meta)) { echo $meta; } ?>
do you want this: <?php global $wp_query; $postid = $wp_query->post->ID; $meta = get_post_meta($postid, ‘direccion’, true); if(!empty($meta)) { echo $meta; } ?>
The value of the textarea must be printed between the opening and the closing tag: <form action=”https://wordpress.stackexchange.com/”> <textarea name=”whatever”><?php echo esc_textarea( $description ); ?></textarea> </form> Note the usage of the function esc_textarea() here. It prevents any possible character inside the variable $description from being interpreted as HTML. It’s an important step to avoid possibly XSS … Read more
This is known as array dereferencing and is only available in PHP 5.4+ To support older versions, you need to assign the array, and then access the index: $data = get_post_meta( $product_id, ‘_product_image_gallery’ ); $gallery_pictures_id = $data[0]; Having said that, in your case use the third argument “single”: $gallery_pictures_id = get_post_meta( $product_id, ‘_product_image_gallery’, true );
You have a structural problem with your data. Serialized data in the database is terrible if you need to search over pieces of that serialized data. There is no reliable, efficient, and certainly no easy, SQL query to search over serialized data. “serialization” is a PHP mechanism. It isn’t SQL. To the database that is … Read more
I’ve answered my question… when your not giving the id of the post meta … it’s creating another one … you give the id and it’s updating… –
why not add a filed to user meta once they have voted and just check to see if that specific user can vote? add to your add vote function this lines: global $current_user; get_currentuserinfo(); add_user_meta( $current_user->ID , ‘voted’, true ); now if a user votes it saves a usermeta filed. then you can create a … Read more
add_action( ‘manage_post_custom_column’, ‘price_column_display’, 10, 2 ); This line is wrong. I think it should be: add_action( ‘manage_catalog_post_custom_column’, ‘price_column_display’, 10, 2 ); The hook format is as follows: manage_{$post_type}_posts_custom_column EDIT: try your custom column code like the following code. I know in this format it works: add_action(‘manage_stores_posts_custom_column’, ‘sc_stores_manage_columns’, 10, 2); function sc_stores_manage_columns($column_name, $id) { $custom = … Read more
This should do the trick: global $wpdb; $parent = 1; // Make sure it’s int (intval() it) as it’s not escaped in the query $posts = $wpdb->get_results( “SELECT `post_id` AS `ID`, `meta_value` AS `Progress` FROM {$wpdb->postmeta} WHERE `meta_key`=’task_progress’ AND `meta_value` < 100 AND `ID` IN (SELECT `post_id` FROM {$wpdb->posts} WHERE `post_parent`={$parent}) ORDER BY `meta_value` DESC, … Read more
Instead of exporting raw SQL, instead us eth eWordPress exporter and import them that way. This way any media attachments, taxonomy terms, and post meta are all included, and all URLs are adjusted too
On which hook of WP init this code part? $user_id – why and from how is this var value? update_post_meta() will use the post ID, see Codex.