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

esc before saving or before displaying does it matter?

Yes it does. Escaping depends on context and in worst case like using esc_html when writing directly to the DB are just a security hole. Even if there is no security issue, there is theoretical one. The user asked you to store A, and you are storing B. In a simple cases B is exactly … Read more

Categories metabox Tags escaping, metabox, post-meta

Save metabox with multiple checkbox array

Try the following code. add_action( ‘add_meta_boxes’, function() { add_meta_box( ‘custom-metabox’, ‘Select values’, ‘fill_metabox’, ‘post’, ‘normal’ ); }); function fill_metabox( $post ) { wp_nonce_field( basename(__FILE__), ‘mam_nonce’ ); // How to use ‘get_post_meta()’ for multiple checkboxes as array? $postmeta = maybe_unserialize( get_post_meta( $post->ID, ‘elements’, true ) ); // Our associative array here. id = value $elements = … Read more

Categories plugin-development Tags custom-field, metabox, plugin-development, post-meta

How to get meta box data to display on a page

To show post type meta data on a single page template, I assume that you’re in the Loop. // Use get_the_ID() to get the ID via the API function echo get_post_meta( get_the_ID(), ‘my-info’, true ); // You can also call it from the global, as the query refers to the current single page echo get_post_meta( … Read more

Categories metabox Tags metabox, post-meta

Display all meta for a post?

To get all rows, don’t specify the key. Try this: $meta_values = get_post_meta( get_the_ID() ); var_dump( $meta_values ); // so you can see the structure

Categories PHP Tags php, post-meta

How much faster is a tax query than a meta query?

I’m not sure that one can be called categorically faster than the other. And, in any case, it’s only really going to emerge when you start to scale up to many, many objects. The issue is this: The postmeta table is a key-value table that is not indexed. If you have a certain number of … Read more

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

display specific custom fields

You should use get_post_meta() twice (Ref to your other question): <?php echo get_post_meta( get_the_ID(), ‘club’, true ); echo ‘<br />’; echo get_post_meta( get_the_ID(), ‘date’, true ); ?>

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

Why time functions show invalid time zone when using ‘c’ time format?

The issue is that for correct output WP needs to process date through date_i18n() function. When you use date format, hardcoded in PHP code (not simply saved in PHP DATE_* constant) like ‘c’ – it’s not available to your code and so for WP to process. System-wide fix would be to re-process date with analogous … Read more

Categories post-meta Tags date-time, post-meta, timestamp, timezones

How to access the post meta of a post that has just been published?

Solved it! Used save_post to run push_notification() as well as to run the function save_post_meta() that saves my post meta. The problem occurred coz push_notification() gets fired before save_post_meta() due to which the meta wasn’t being saved and therefore it remained inaccessible. Just changed priorities of the functions to make it work like so : … Read more

Categories post-meta Tags post-meta, publish

WP-CLI How to generate a list of posts with corresponding meta values

Just figured it out. This isn’t clearly or explicitly documented at https://developer.wordpress.org/cli/commands/post/list/ or elsewhere. wp post list –fields=ID,post_title,Amazon.com,Amazon.co.uk –meta_key=Amazon.com –meta_key=Amazon.co.uk

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

Redirect blog page to latest post?

You can use the get_posts() function: <?php /* Template Name: Redirect */ $args = array( ‘posts_per_page’ => ‘1’, ‘post_type’ => ‘post’ ); $post = get_posts($args); if($post){ $url = get_permalink($post[0]->ID); wp_redirect( $url, 301 ); exit; }

Categories redirect Tags post-meta, redirect
Older posts
Newer posts
← Previous Page1 … Page188 Page189 Page190 … 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