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

sanitize meta input

You need to escape data while displaying also. Use esc_attr in your case. Try this: <input type=”text” name=”field_name” value=”<?php echo (!empty($field)) ? esc_attr( $field ) : ”; ?>” /> Check this for full documentation – https://codex.wordpress.org/Data_Validation

Categories post-meta Tags post-meta, sanitization, validation

Saving a meta value as an object using useEntityProp

And yet, the post meta is stored in the database as a serialized array! This is because all meta values are strings, that’s what the database table schema says. So if you try to pass structured data into it, WordPress tries to be helpful and uses serialize to turn it into a string, then deserialises … Read more

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

How do I access the current post object within a block theme template or pattern?

While working with the block themes and block patterns, we can access post data or metadata through given methods. By using render_callback in register_block_pattern register_block_pattern( ‘your-theme/custom-pattern’, array( ‘title’ => ‘Custom Pattern’, ‘content’ => ‘<!– wp:paragraph {“placeholder”:”Write something…”} /–>’, ‘categories’ => array( ‘text’ ), ‘render_callback’ => function() { $post_id = get_the_ID(); // Here we have access … Read more

Categories theme-development Tags full-site-editing, post-meta, query-posts, theme-development

Add specific postmeta to search query

For WP_Query(), you don’t need to add the % before and after the keyword when using LIKE as comparison. WP_Query() will handle it for you. If you add %, WP_Query() thinks that you want to add that character itself to the search. That’s the first reason you don’t see any results. The second problem is … Read more

Categories post-meta Tags post-meta, search

Footnotes are not copied as a block

There were attempts to add footnotes support to core for several years, with several approaches being explored. It was decided to store them in post meta to make it easier to render the footnotes outside of the post content in templates. See: https://github.com/WordPress/gutenberg/pull/51201

Categories post-meta Tags post-meta

Block that displays post meta as nested block of Query Loop

You don’t want to use getCurrentPostId() from the core/editor store. This gets the current post ID from the post being edited, not the post in the query loop. To get that, ensure your block accepts postId (and possibly postType) as block context values via the usesContext key in the block type metadata. This can be … Read more

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

What is the best way to get a different post’s custom field/postmeta with js?

Here’s a way that could be “best” depending on the circumstance: const { meta } = wp.data.select( ‘core’ ).getEntityRecord( ‘postType’, ‘post’, 123 ); This tutorial might be helpful for related stuff.

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

Hide individual page title using checkbox in custom meta box?

$value is always empty because post ID is missing. Pass the parameter ($post object) to the hide_title_callback() function and get the post ID right way. Also, you should take care of nonces. <?php // pass the $post object function hide_title_callback( $post ) { // you have to verify this nonce inside `mysite_save_postdata()` // https://codex.wordpress.org/Function_Reference/wp_nonce_field wp_nonce_field( … Read more

Categories post-meta Tags metabox, page-template, post-meta, title

Block Editor – Meta values not saved, meta changes to empty array on update

So, in my case, the answer was simple, though it took a long time to find. Just in case anyone else ever has this issue, here is what solved it for me: I was calling the register_post_meta in a file that was only being included if is_admin() returns true (this is a plugin metabox conversion, … Read more

Categories custom-field Tags block-editor, custom-field, meta-value, post-meta

How to append $metadata[‘sizes’] to metadata when using ‘wp_generate_attachment_metadata?

Although the suggested answer from admcfajn wasn’t the solution to the problem/question, it did lead me to look explore it further. Thanks admcfajn. Assuming you are using either the default intermediate e.g. thumbnail or custom sizes e.g. 320w and would like to include additional sizes such as full, you can use wp_update_attachment_metadata( $attachment_id, $metadata );

Categories post-meta Tags attachments, post-meta
Older posts
Page1 Page2 … 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