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

Can’t get post ID using wp_insert_post_data

From the codex page You must pass 2 for the $accepted_args variable in add_filter() if you want to access $postarr. So use this: add_filter( ‘wp_insert_post_data’, ‘set_post_title’, 99, 2 );

Categories custom-field Tags custom-field, post-meta, wp-insert-post

How to get update_post_meta output to include string length

Your data is being serialize properly. Your code saves an array of integers. Integers are not strings and so a string length is not saved. Run the following code and it should illustrate the point: $str=”a:4:{i:0;s:4:”7613″;i:1;s:4:”7615″;i:2;s:4:”7616″;i:3;s:4:”7618″;}”; $str = maybe_unserialize($str); var_dump($str); echo ‘<br/>’; var_dump(maybe_serialize($str)); echo ‘<br/>’; $str = array( 1234,4567,8910,1112 ); var_dump(maybe_serialize($str)); echo ‘<br/>’; $str = … Read more

Categories array Tags array, post-meta

Structure of postmeta meta_value for woocommerce product download

In short, this is serialized data and this is how data is stored from a custom field (and many other datastrings) in the db. s:114 is auto generated and simply means that the value http://localhost/wp-content/uploads/woocommerce_uploads/2014/09/test-file.pdf is a string and is 114 characters long. This is used when the data is read and used. If the … Read more

Categories Database Tags database, post-meta, woocommerce-offtopic

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

How to create html block to display extra information on woocommerce single product page

To begin with you may need to add %s to the sprintf function, as the current link has no anchor text and this is supposed to be put in by sprintf as the second argument: return sprintf( ‘<div class=”form-block block-after-indent”><a class=”atbtn atbtn–secondary1″ href=”#sime_url_product_id_%d”>%s</a></div>’, $product->id, esc_html( $product->get_title() ) );

Categories custom-field Tags custom-field, post-meta, woocommerce-offtopic

Meta Key Value in current-user-only loop

There is no $post var local to your function, you need to use global $post first, or get_the_ID(). get_post_meta( get_the_ID(), ‘_cf_address’, true );

Categories custom-post-types Tags custom-field, custom-post-types, loop, post-meta

Randomly Assign an Image’s Alt Text Based on Data From Post

Just set the image alt text when the image is saved. Hook onto the save_post action, check if any of the attached images don’t have alt text, and if not then generate the alt text you want and save it with: update_post_meta( $attachment_id, ‘_wp_attachment_image_alt’, ‘this is the alt text’ );

Categories PHP Tags custom-taxonomy, php, post-meta, post-thumbnails

Where does the actual data stored by add_post_meta

Yes, we can use existing tables in WordPress for storing the values. Post meta fields are stored in the {$wpdb->prefix}_postmeta table (depending on the table prefix; wp_postmeta by default). If the meta key “like_count” is already present in the table along with the post ID then update_post_meta() will update this, and otherwise this function will … Read more

Categories Database Tags database, post-meta

Trying to remove post thumbnail with plugin

I found where the problem was. The code was attached to the the_content hook which runs after the thumbnail is generated. Attached the code to post_thumbnail_html and it works now.

Categories PHP Tags php, post-meta, thumbnails

Populate dropdown from one custom post type inside another custom post type

You need to query the db using wp_query to get all the posts from the CPT, save the metabox contents to an array and then print the array. Not tested but should work (i hope): <?php $select_array = array(); $args = array ( ‘post_type’ => ‘your_cpt’, ); $query1 = new WP_Query( $args ); while ( … Read more

Categories custom-post-types Tags custom-post-types, metabox, post-meta
Older posts
Newer posts
← Previous Page1 … Page144 Page145 Page146 … Page204 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