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

Identifying Importer Posts

Two things I could imagine: Check the post_modified value. Maybe import creates a definitive timestamp that you could use. You’ll still have to save the import date somewhere so you can check against it. I do some post importing via a stream/HTTP response (this is not the native importer). During the import, I map my … Read more

Categories post-meta Tags bulk-import, import, post-meta

Function to change meta value in database for each post

You’ll only need to run it once, but this should get all your posts, and then loop through them and update the meta. add_action(‘admin_init’, ‘deleteCommaDB’); function deleteCommaDB(){ // The Query $args = array ( ‘posts_per_page’ => -1 ); $the_query = new WP_Query( $args ); // The Loop while ( $the_query->have_posts() ) : $the_query->the_post(); $price_key = … Read more

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

Custom fields: In what order are they saved into the DB?

The SQL query triggered by get_post_custom() is in update_meta_cache() and it looks like this: $wpdb->get_results( $wpdb->prepare( “SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list)”, $meta_type ), ARRAY_A ); So there is no ORDER BY given. Without ORDER BY the resulting order is almost unpredictable: it depends on the optimizer, used indexes and their … Read more

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

Custom fields to save multiple values

First, dd this code [] at the end of your form field name. So your field’s name will be “test[]”. Example: <input type=”text” name=”test[]” value=”” size=”60″ /> Use this way to save the value: $old = get_post_meta($post_id, ‘your_meta_key’, true); $newtest = array(); $test = $_POST[‘test’]; $count = count( $test ); for ( $i = 0; … Read more

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

Exporting Data from WordPress into a flat table

Problem is that meta values are not unique key/value data. E.g. with the key ‘OneKey’ you can have a lot of values for the same post. So, in a flat table, for the column ‘OneKey’ you should have multiple rows where the post id is the same and seems to me is not what you … Read more

Categories posts Tags database, export, meta-query, post-meta, posts

How to add multiple featured image in meta box in post editor?

I know you said you were looking for your own implementation, but the easiest way to add multiple featured image metaboxes is with the Multiple Post Thumbnail plugin. Following the plugin’s documentation, the way to define a secondary box is to add this code to your theme’s functions.php if (class_exists(‘MultiPostThumbnails’)) { new MultiPostThumbnails( array( ‘label’ … Read more

Categories custom-post-types Tags custom-post-types, metabox, plugin-development, post-meta, post-thumbnails

How to keep a check box in custom meta box for custom post type checked by default for add new post?

save_post being called multiple times is expected behavior, but because of how it’s used, you may not always want your code to execute until the user actually clicks on the save button. Like you have mentioned above regarding your requirement. So you can check the current page ( i.e post-new.php ) in the wp-admin and … Read more

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

Automatically adding meta data to posts or multiple query help

This will query all the ticket posts and update a _ticket_date field. However, I’m not yet sure how to retrieve the actual date, so you’ll have to provide me with a little more information for that. Assuming it works properly I would run the following once, and then remove. You could achieve a similar effect … Read more

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

Consolidate Metaboxes into 1 Big Metabox

Register your taxonomies with ‘show_ui’ => false, and then add a single meta box to manage them. function create_book_tax() { register_taxonomy( ‘genre’, ‘book’, array( ‘label’ => __( ‘Genre’ ), ‘rewrite’ => array( ‘slug’ => ‘genre’ ), ‘hierarchical’ => true, ‘show_ui’ => false, ) ); } Or unhook the boxes from the side panel and put … Read more

Categories metabox Tags metabox, post-editor, post-meta, taxonomy

Are multiple values from get_post_meta guaranteed to be ordered?

Yes. get_post_meta() uses get_metadata() which in turn uses update_meta_cache() to retrieve the values. In the source code we see this part (comment mine) // $id_column is ‘meta_id’ $meta_list = $wpdb->get_results( “SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list) ORDER BY $id_column ASC”, ARRAY_A ); So the meta values will be ordered by meta_id … Read more

Categories post-meta Tags post-meta
Older posts
Newer posts
← Previous Page1 … Page170 Page171 Page172 … 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