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

What is the difference between update_post_meta and update_postmeta hooks?

They were both introduced in version 2.9, but were done so in different files. update_postmeta went into /wp-admin/includes/post.php While… update_{$meta_type}_meta went into /wp-includes/meta.php It was only later that update_postmeta was shifted into /wp-includes/meta.php. So I believe it was for backward compatability, where by because the update_postmeta hook was always receiving the value of maybe_serialize() then … Read more

Categories hooks Tags core, hooks, post-meta

post formats – how to switch meta boxes when changing format?

I did something like this once, but when you clicked on a certain category (essentially the same) It certainly isn’t a true ajax solution, it just hides and reveals the div with the settings, but It is a solution which works. You’ll definitely have to modify this for your needs, but if you have a … Read more

Categories post-meta Tags ajax, metabox, post-formats, post-meta

Sanitizing integer input for update_post_meta

For integers KSES has no special function. Use (int) or intval() or absint() See more: Data Validation – Integers

Categories post-meta Tags input, post-meta, sanitization

meta_query: using BETWEEN with floats and/or casting to DECIMAL

You can filter generated SQL and add precision parameters that you need. Enable filters for get_posts() by adding following to query: ‘suppress_filters’ => false, And: add_filter(‘posts_where’,’cast_decimal_precision’); function cast_decimal_precision( $where ) { return str_replace(‘DECIMAL’,’DECIMAL(10,3)’,$where); } Update With Jan’s suggestion: add_filter(‘get_meta_sql’,’cast_decimal_precision’); function cast_decimal_precision( $array ) { $array[‘where’] = str_replace(‘DECIMAL’,’DECIMAL(10,3)’,$array[‘where’]); return $array; }

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

How to edit a post meta data in a Gutenberg Block?

Think I found the answer here. The first argument to register_meta is not post type but object_type, which is in my case should be post rather than taxonomy or comment. The function description, found here, states as of WordPress 4.9.2 the correct parameter is post. Once I switched it everything worked. register_meta(‘post’, ‘event_location’, [ ‘show_in_rest’ … Read more

Categories post-meta Tags block-editor, post-meta

Order by optional meta key?

Completely edited after first publish The problem is that to order for a meta value, WordPress need to ‘meta_key’ in query is set to something. But if you set ‘meta_key’ to something, then WordPress will add something like AND ( wp_postmeta.meta_key = ‘the_meta_key’ ) to WHERE SQL clause; and something like INNER JOIN wp_postmeta ON … Read more

Categories wp-query Tags order, post-meta, wp-query

Best way to programmatically remove a category/term from a post

Hmmm, can’t remember or find fitting function either. There is wp_set_object_terms() that is used in multiple wrappers like wp_set_post_categories(). It can overwrite categories for a post. So you can get post categories, check for unwanted one and write it back excluding unwanted in that case.

Categories custom-field Tags api, custom-field, post-meta, taxonomy

Save camera info as metadata on image upload?

You can use wp_generate_attachment_metadata: This function generates metadata for an image attachment. It also creates a thumbnail and other intermediate sizes of the image attachment based on the sizes defined on the Settings_Media_Screen. The second argument of the filter is the attachment ID, so it shouldn’t be a problem to add the post meta: add_filter( … Read more

Categories uploads Tags post-meta, uploads

What is the different between an attachment in wp_posts and an attachment in wp_postmeta?

An attachment is a Post The posts table contains information on the attachment post. In WordPress every uploaded media has it’s own post entry, where post_type is ‘attachment’ and post_status is ‘inherit’. In fact, you can get attachment post types using functions used to get other post types, like post, page or any CPT. That … Read more

Categories post-meta Tags attachments, post-meta, woocommerce-offtopic

The “_encloseme” Meta-Key Conundrum

Short version: _encloseme is added to a post when it’s published. The wp-cron process should get scheduled shortly thereafter to process the post to look for enclosures. In other words, it cleans them up normally later. Nothing to worry about. Full explanation: “Enclosures” are links in a post to something like an audio or video … Read more

Categories custom-field Tags custom-field, post-meta
Older posts
Newer posts
← Previous Page1 … Page198 Page199 Page200 … 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