Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

post-meta

running function during post save and adding variable to post meta

Yes, most definitely. Take this skeleton code below as a base for a function that would do what you want, and place it in your functions.php: function your_vimeo_meta_function ($post_id) { // some verifications first if ( $post_id == null || empty($_POST) ) return; if ( !isset( $_POST[‘post_type’] ) || $_POST[‘post_type’]!=’post’ ) return; if ( wp_is_post_revision( … Read more

Categories post-meta Tags post-meta

“update_post_meta” not working in “wp_insert_post_data” hook

Two issues with your code in current form: wp_insert_post_data hook runs before the actual insertion happens. In other words post might not not exist yet. Data in this hook does not contain post_id. More fitting hooks to use are those after post insertion is processed: do_action(‘save_post’, $post_ID, $post); do_action(‘wp_insert_post’, $post_ID, $post);

Categories post-meta Tags post-meta

WordPress front-end media (image) upload ERROR!

Yes, got the problem. A minute off-track, and it’s wrong! :p On line 80, 87, 93 and 99 in Pastebin Codes, the syntax of media_handle_upload() was wrong. It should be substituted from media_handle_upload($postid,’product_image_1′); to media_handle_upload(‘product_image_1’, $postid); Because the syntax of media_handle_upload() is: media_handle_upload( $file_id, $post_id, $post_data, $overrides ); The $post_id cannot be before $file_id.

Categories post-meta Tags post-meta, uploads

How to use update_post_meta inside wp_trash_post

The Core “trash post” links in the “Quick Edit” section on edit.php and in the “advanced” form in the “Publish” meta box work over GET not POST. Unless you have altered the form(s) somehow, there is no POST data. All you have is the post ID. To save data when a post is deleted, you … Read more

Categories post-meta Tags post-meta, trash

Set Checkbox as checked by default

You should use delete_post_meta( $post->ID, ‘show_links’ ); instead of delete_post_meta( $post->ID, ‘show_links’, 1 ); the last form is used to delete specific values when you have multiple values with the same key. Here you most probably already stored a value which is an empty string that you never deleted and that’s what you get when … Read more

Categories post-meta Tags post-meta

populate post meta in gravity forms [closed]

You have the arguments for get_post_meta backwards. You have: get_post_meta(‘imail’, $post->post_id); Whereas, where you to check the Codex, it should be: get_post_meta( $post_id, $key, $single ); Or is your case: get_post_meta($post->post_id,’imail’); That is assuming that $post is set correctly and that you are using the Gravity Forms hooks correctly.

Categories post-meta Tags plugin-gravity-forms, post-meta

get_*_meta doesn’t always return an array

I normalize the output of these functions using this logic: Cast the value to an array. If it is not an array already, it will be converted to an array with one element, which is the value it was, e.g. (array) false becomes array (false). Use array_filter, which, when not passed a callable, simply filters … Read more

Categories post-meta Tags array, php, post-meta, user-meta

echo image caption

Retrieve caption of image correct format is <?php $post_thumbnail_id = get_post_thumbnail_id( $post_id ); ?> <?php function wp_get_attachment( $attachment_id ) { $attachment = get_post( $attachment_id ); return array( ‘alt’ => get_post_meta( $attachment->ID, ‘_wp_attachment_image_alt’, true ), ‘caption’ => $attachment->post_excerpt, ‘description’ => $attachment->post_content, ‘href’ => get_permalink( $attachment->ID ), ‘src’ => $attachment->guid, ‘title’ => $attachment->post_title ); } $at= wp_get_attachment($post_thumbnail_id); … Read more

Categories post-meta Tags captions, images, post-meta, twitter-bootstrap

Echo page title from page with custom meta datetime picker

This should output the title of the page with the most recent timestamp: $args = array( ‘post_type’ => array( ‘page’ ), ‘order’ => ‘DESC’, ‘orderby’ => ‘meta_value_num’, // Note was `meta_value` before ‘meta_key’ => ‘_cmb_test_datetime_timestamp’, ‘numberposts’ => 1, ); $posts = get_posts( $args ); if ( $posts ) echo $posts[0]->post_title; wp_reset_postdata(); To add conditions, use … Read more

Categories post-meta Tags post-meta

Update post meta in woocommerce order frontend

I came across this post looking for a solution for multiple resubmissions due to update_post_meta. Here’s my solution after looking at these posts wordpress get_post_meta check if multiple values set Prevent processing data multiple times in Woocommerce thankyou hook : <?php global $post; $post = $order_id; if ( isset( $_POST[‘submit’] ) ){ echo ‘Update nicht’; … Read more

Categories post-meta Tags front-end, post-meta, woocommerce-offtopic
Older posts
Newer posts
← Previous Page1 … Page36 Page37 Page38 … Page51 Next →
+ More

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 2026 Read For Learn
Next Page »
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress