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

Correct processing of `$_POST`, following WordPress Coding Standards

Correct processing of `$_POST`, following WordPress Coding Standards

Categories post-meta Tags coding-standards, post-meta, sanitization, save-post

How do I add advanced custom fields / meta fields to Elasticsearch? [closed]

Lets break this down, Advanced Custom Fields (ACF) does save the data as custom field/post meta, I guess it seems all to obvious, but it is better to confirm it, and ElasticPress does set up custom fields automatically to include them into the search index. ElasticPress does this unless the meta data is hidden, which … Read more

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

Order posts by meta value and Date

If you want both posts that have and do not have a meta key, you need an OR relation meta query to select both posts with key and those where it does not exist. $args = array( ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘_post_like_count’, ‘compare’ => ‘EXISTS’ ), array( ‘key’ => ‘_post_like_count’, … Read more

Categories wp-query Tags meta-query, post-meta, recent-posts, wp-query

How metadata API works?

Q1 Yes, you can store serialized arrays as a single meta key, eg: update_post_meta( $post_id, ‘my_items’, array( 1, 2, 3, 4 ); Furthermore, you can store multiple values against a single meta key, eg: add_post_meta( $post_id, ‘my_items’, 1 ); add_post_meta( $post_id, ‘my_items’, 2 ); The latter is preferred because meta queries can be more efficiently … Read more

Categories post-meta Tags meta-query, post-meta

get_post_meta returns bool(false)

Apparently the serialized data got corrupt, calling the field by query got me this error. WordPress does not return an error when the serialized data is corrupt just a bool(false). Solved this by insert/update the serialized data in a base64_encode() and call it with base64_decode(). This seems to do the trick and data can be … Read more

Categories post-meta Tags post-meta

Is there a way to list tags order by post_meta field

$querystr = ” SELECT DISTINCT — post_meta.meta_value, key2.name as tag_name,key2.slug as tag_slug FROM $wpdb->posts key1 LEFT JOIN $wpdb->term_relationships ON (key1.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->postmeta post_meta ON (key1.ID = post_meta.post_id) LEFT JOIN $wpdb->terms key2 ON ($wpdb->term_relationships.term_taxonomy_id = key2.term_id) LEFT JOIN $wpdb->term_taxonomy key3 ON ($wpdb->term_relationships.term_taxonomy_id = key3.term_id) WHERE 1=1 AND post_meta.meta_key = ‘likes_count’ AND post_meta.meta_value > … Read more

Categories plugin-development Tags plugin-development, post-meta, tags

update_post_meta not working in save_post

A little late, but I just had this issue where adding a taxonomy term was working, but adding post meta wasn’t. The solution was to set a higher priority. The default priority is 10, so try for instance priority of 100: add_action( ‘save_post_dealer’, ‘save_dealer_long_lat’, 100, 1);

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

Add a post metadata if only the key and value does not exist

OK, so you have some code that uses add_post_meta and you want to make it add only unique values. The problem in here is that add_post_meta does exactly what it’s name is saying – it adds a post meta value. There is 4th arg for that function that’s called unique, but it work based on … Read more

Categories post-meta Tags post-meta

Regenerate missing _wp_attachment_metadata

Running the wp media regenerate command from WP-CLI with the –only-missing argument is quite fast (takes about 30 seconds for 4000 images) and rebuilds _wp_attachment_metadata correctly: wp media regenerate –only-missing

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

Get post from meta_key and meta_value

You can get using this using SQL global $wpdb; // For single record $wpdb->get_row(“SELECT post_id FROM $wpdb->postmeta WHERE meta_key = $param1 AND meta_value = $param2”); // For multiple records $wpdb->get_results(“SELECT post_id FROM $wpdb->postmeta WHERE meta_key = $param1 AND meta_value = $param2” ); Use this for query $args = array( ‘posts_per_page’ => 10, // -1 for … Read more

Categories post-meta Tags post-meta, sql
Older posts
Newer posts
← Previous Page1 … Page167 Page168 Page169 … Page203 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