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 to update single value in multi dimensional Post Meta?

You may need to unserialize the data to get the array and loop through it thus: $userid = 832; // or 1540 $votes = get_post_meta($postid,’voter’); $votes = maybe_unserialize($votes); if (is_array($votes)) { // votes is the array, key is numeric index, vote is subarray foreach ($votes as $key => $vote) { // subarray values are in … Read more

Categories PHP Tags array, meta-query, php, post-meta

Should I sanitize custom post meta if it is going to be escaped later?

Short Answer: If you have properly validated the data, then sanitization can be made optional. Longer Answer User-supplied data and data from unknown/external sources should always be treated as untrusted even in the case where the user was actually yourself, so yes, we should always validate and/or sanitize such data. And therefore, no, please do … Read more

Categories post-meta Tags post-meta, sanitization

importing data from non-wordpress mysql db

you need to get the ID back from your post insertion and use that with add_post_meta: $post_id = wp_insert_post($post); add_post_meta($post_id, ‘thumbnail’, $yourvalue, true);

Categories custom-field Tags custom-field, database, import, mysql, post-meta

Search everything (posts, pages, tags, cpt, meta)

DeluxeBlogTips.com 1) has an article on how to do combined searches in both posts and meta data. Basically, it involves two queries via the $wpdb object; one to search the meta table to get a list of post_ids and the other is a query of posts to get post_ids. You then merge the arrays and … Read more

Categories custom-post-types Tags custom-field, custom-post-types, functions, post-meta, search

delete unused postmeta

Does the unused postmeta affect the speed of my database? Anything in your database affects the speed of your database. The question is how much of a slowdown, and if the amount of data is significant enough. Unless your having a huge amount of metadata it will not affect the speed of your database very … Read more

Categories post-meta Tags mysql, post-meta

Migrating non-WordPress CMS to WordPress, lots of data to move — possible solutions?

I would suggest inserting your tours as posts (or custom posts) and using a custom reference table with the id matching the post id of the Tour post. You could use WordPress’s built in meta box functions to be able to edit each Tour in the edit posts page. You could update your reference table … Read more

Categories Database Tags cms, database, migration, mysql, post-meta

Save HTML formatted data to post meta using add_post_meta()

Is it that your tags are being stripped, or that you aren’t preparing them prior to displaying them. Try wrapping your output: echo apply_filters(‘the_content’, get_post_meta($post->ID, ‘_custom_field_name’, true));

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

How to use multiple query with same meta key

to store multiple values in same custom field key and print them at once If you want to store it as site option, you can use update_option() : http://codex.wordpress.org/Function_Reference/update_option Example 1: // some array to store: $items=array(‘yellow’,’orange’,’green’); // save the array update_option(‘myitems’,$items); // get the array $items=get_option(‘myitems’); // print the array echo “<ul>”; foreach($items as … Read more

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

Multiple meta values for same meta_key adding on “Preview Changes” hit but not on saving or updating post

Actually I’d love to have an answer from @ialocin, because he suggested me the way. But as the code is a bit long for comment field I’m posting it here as an answer. But I’d love to accept an answer more appropriate to the situation: After @ialocin’s suggestion, I got that, the $post_id wasn’t accurate … Read more

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

WPDB Multiple site’s posts and get featured images

This is one way how to get the postmeta of the posts, by joining the postmeta table and fetching the _wp_attached_file meta value. Try this: $mydb->get_results( select a.*, thumb.meta_value from wp_posts a left join (select b.post_id, c.meta_value from wp_postmeta b, wp_postmeta c where b.meta_key = ‘_thumbnail_id’ and b.meta_value = c.post_id and c.meta_key = ‘_wp_attached_file’) as … Read more

Categories multisite Tags multisite, post-meta, query, wpdb
Older posts
Newer posts
← Previous Page1 … Page184 Page185 Page186 … 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