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

How Can I save multiple records in same meta key?

This should work out of the box, as long as the “unique” parameter of add_post_meta() is false. add_post_meta($id, ‘_dates’, 2, false); add_post_meta($id, ‘_dates’, 3, false); add_post_meta($id, ‘_dates’, 4, false); then somewhere else $dates = get_post_meta($id, ‘_dates’, false); Now $dates should be an array of your 3 values.

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

How to create a mini directory in WordPress?

Sounds like what you want is to use Custom Post Types with custom fields to create your own directory. Here’s an answer I wrote about exactly that: Tips for using WordPress as a CMS? Implementing a CrunchBase.com Clone using WordPress? Also, take a look at the SimpleFields plugin for WordPress which can help you create … Read more

Categories custom-post-types Tags custom-post-types, directory, post-meta

Post metadata deletes itself

I’ve been using this for a while to solve exactly your issue, I think I got it from the codex somewhere. But it works. // verify if this is an auto save routine. // If it is our form has not been submitted, so we dont want to do anything if ( defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE … Read more

Categories custom-post-types Tags custom-post-types, post-meta

How to delete outdated, wrongly sized images in _wp_attachment_metadata?

Not from personal experience (I don’t use WP image management much), but I believe Regenerate Thumbnails plugin is usually recommended for rebuilding thumbnails.

Categories Database Tags customization, database, images, post-meta

How to programmatically create a connection with [Plugin: Posts 2 Posts] on cpt publish?

Just call p2p_connect( $id_of_post_type_a, $id_of_post_type_b ); in the form handling code.

Categories custom-post-types Tags custom-post-types, plugin-posts-to-posts, post-meta, publish

How to batch update post content with custom post meta value

what about something like this on activation? function wpa47153_run_once(){ $posts = get_posts(array(‘numberposts’ => -1) ); foreach($posts as $p) : $meta = get_post_meta($p->ID, ‘meta_key’,true); if($meta) : $my_post = array(); $my_post[‘ID’] = $p->ID; $my_post[‘post_content’] = $meta . “<br/>” . $p->post_content ; // Update the post into the database wp_update_post( $my_post ); unset($my_post); //remove the meta key delete_post_meta($p->ID, … Read more

Categories posts Tags metabox, post-meta, posts, updates, wp-update-post

Why is get_post_meta returning an array when I specify it as single?

This works fine if I’m only returning data for a single meta key…but fails if I want to return all of the meta data, but return them all as strings (single). This doesn’t make a lot of sense. A function in PHP can only return a single value so there is no way to return … Read more

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