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

WP REST API “rest_no_route” when trying to update meta

Here is what I have learned about the WP REST API: It is a mess of undocumented and unfinished code with great promise but frustratingly little clarity. That said, I have a workaround that I will post here, hoping it is useful to others in a similar pickle to me: I just found that I … Read more

Categories post-meta Tags post-meta, rest-api

How to get meta value in wp_attachment_metadata

There are two methods: get_post_meta() $attachment_meta = get_post_meta( $post->ID, ‘_wp_attachment_meta’, true ); Will return an array(): $width = $attachment_meta[‘width’]; That true as the third parameter is especially important in this case, since the metadata being queried is a serialized array. You need to return it as single, or you’re going to get an array returned, … Read more

Categories post-meta Tags attachments, images, post-meta

Give extra post-meta to RSS feeds

WordPress uses SimplePie for reading feeds, not for generating feeds. You’re looking at two different things here: You want to output your custom post meta in an RSS feed. You want to read that custom post meta somewhere else. The first part is pretty easy. WordPress supports custom RSS feed templates. You can actually replace … Read more

Categories post-meta Tags post-meta, rss, simplepie

Get Advanced Custom Fields values before saving [closed]

Edit – This answer is no longer accurate for the current version of ACF, see their documentation Use the acf_save_post hook. function my_acf_save_post( $post_id ) { // vars $fields = false; // load from post if( isset($_POST[‘fields’]) ) { $fields = $_POST[‘fields’]; } // … } // run before ACF saves the $_POST[‘fields’] data add_action(‘acf_save_post’, … Read more

Categories post-meta Tags advanced-custom-fields, post-meta

Save both current and new version of post meta

that could be caused by post revision being saved, and you should use wp_insert_post_data anytime you want to do something before the post is saved, here is an example plugin i just cooked up to test it and it looks like this: <?php /* Plugin Name: wpse37901 Plugin URI: http://en.bainternet.info Description: answer to http://wordpress.stackexchange.com/questions/37901/save-both-current-and-new-version-of-post-meta Version: … Read more

Categories post-meta Tags duplicates, post-meta

Query between two meta values?

Edited again to demonstrate adding and removing filters: Include these general functions in your functions.php. These are the filters you will invoke for the loops where you want to limit your query by these two meta values: function date_check_join( $join ) { global $wpdb; $join .= ” JOIN “.$wpdb->postmeta.” AS startdate ON (“.$wpdb->posts.”.ID = startdate.post_id … Read more

Categories post-meta Tags date-time, post-meta, sql

Front-end update_post_meta snippet displays white screen?

Change your nonce verify to actually verify and update post meta, else do nothing. But don’t use exit at the top of your template. // top of page if ( isset( $_POST[‘drw_inventory’] ) && wp_verify_nonce($_POST[‘drw_inventory’],’update_drw_postmeta’) ) { //if nonce check succeeds. global $post; $postid = $post->ID; $data = $_POST[‘priceone’]; update_post_meta($postid,’metakey’,$data); } // in single.php $priceone … Read more

Categories post-meta Tags post-meta

How do I retrieve multi-dimensional arrays from the wp_postmeta table, & display on a website?

When you save an array as post meta, WordPress will serialize it to a string and save that string. Let’s take a simple array: array ( 1 => array ( ‘url’ => “https://wordpress.stackexchange.com/”, ‘title’ => ‘Home’ ), 3 => array ( ‘url’ => ‘http://wordpress.stackexchange.com/’, ‘title’ => ‘WordPress Stack Exchange’ ), 4 => array ( ‘url’ … Read more

Categories post-meta Tags post-meta

Add post meta based on another post meta value before publish post

The solution is using added_post_meta and updated_post_meta hook . Here is the working code . add_action( ‘added_post_meta’, ‘add_custom_field_automatically’, 10, 4 ); add_action( ‘updated_post_meta’, ‘add_custom_field_automatically’, 10, 4 ); function add_custom_field_automatically( $meta_id, $post_id, $meta_key, $meta_value ) { if ( ‘_my_meta_key’ == $meta_key ) { add_post_meta($post_id, ‘_my_new_meta_key’, $meta_value.’to something new’, true); } }

Categories post-meta Tags post-meta, save-post

Should I sanitize custom post meta if it is going to be escaped later?

Short Answer: If you have properly validated the data, then sanitization can be made optional. Longer Answer User-supplied data and data from unknown/external sources should always be treated as untrusted even in the case where the user was actually yourself, so yes, we should always validate and/or sanitize such data. And therefore, no, please do … Read more

Categories post-meta Tags post-meta, sanitization
Older posts
Newer posts
← Previous Page1 … Page45 Page46 Page47 … 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
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 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