Questions tagged [post-meta]

Post meta is a data set in WordPress that contains additional core as well as custom post information.

Post meta is a data set in WordPress that gets saved inside its own table named {$wpdb->prefix}_postmeta. It contains the following columns:

┌──────────┬──────────┬────────────┬──────────┐
│ post_id  │ meta_id  │  meta_key  │meta_value│
├──────────┼──────────┼────────────┼──────────┤
│ 1233456  │ 1234456  │     foo    │   bar    │
├──────────┼──────────┼────────────┼──────────┤
│bigint(20)│bigint(20)│varchar(255)│ longtext │
└──────────┴──────────┴────────────┴──────────┘

The post_id is needed to do JOINs, so the {$wpdb->prefix}_posts table can connect to this table.

The data that gets saved here by core:

  • _edit_lock
  • _edit_last
  • _thumbnail_id

This table also saves the data entered in custom fields.

And it's as well meant to hold additional custom data. If you want to search by custom field with a meta_query, it's better to use a single entry per value. Else you save it as serialized array (which core will do on it's own).

111 questions
1
vote
1 answer

Wordpress multiple meta query

I am trying to get data from below query. I want result between two dates by first key and other key value if equal 1 but query returns value for me only today's date data and in sql add OR relationship. Please help me to figure out the wrong and…
Destroyer.0211
  • 113
  • 1
  • 3
  • 13
1
vote
1 answer

Update product variations prices in Woocommerce with WPDB query

I am using WordPress 4.7.4 and WooCommerce 3.0.5. I updated _sale_price, _price, _regular_price using meta_id with code below: $meta_tbl = $wpdb->prefix.'postmeta'; foreach ($_POST['loop'] as $loop_k => $loop_v) { $wpdb->update( …
Prafulla Kumar Sahu
  • 9,321
  • 11
  • 68
  • 105
1
vote
1 answer

Display wp_post and wp_postmeta

I'm trying to get the below 3 columns for all posts that are in my database user_name post_title pods_field_blog_category user_name and post_title is stored in wp_posts table pods_field_blog_category is stored in wp_postmeta table. below code…
jeez
  • 33
  • 5
1
vote
0 answers

wordpress drag and drop post meta box page builder

I am so tired to try to add a custom options to this my taken free source code for drag and drop purpose. Can any one of you help me to add the custom options to this code. …
1
vote
1 answer

Order by post_meta in wp_query wordpress not working

I want to order posts by price in wordpress, I tried a lot and also concerned by documentation, all looks good but still it is not working.. here is code.... global $wp_query; $query_vars =…
Bilal
  • 51
  • 1
  • 8
1
vote
2 answers

Updating meta_value adding an associative array to those that already exist

What I'm trying to do is to optimize the way to store data in my wp_postmeta table. I need to save multiple relations between posts, and my starting situation was simply this: add_post_meta($parent_id, 'post_child', $child_id); In that way I needed…
supadema
  • 123
  • 1
  • 2
  • 11
1
vote
0 answers

Updating custom field not working properly

I have a custom code to update a custom field from the front end. It loads the data correctly but when I try to change/update the custom field it goes wrong. It updates the meta value, but it has more values. These are the meta values:…
Mark
  • 731
  • 2
  • 10
  • 29
0
votes
0 answers

Is there a way to update post meta schema after meta fields have been saved for a wordpress post

I have register a post meta field called project_description with it's explicit 'schema' in register_post_meta function. The following is register_post_meta function - function register_project_description_post_meta() { register_block_type(…
0
votes
0 answers

Deleting Wordpress Custom Fields Which Aren't Needed

We are looking at the best way we can delete empty custom fields which are being created by one of our Wordpress plugins. This can be achieved by adding the following code to our functions.php file. This works, and prevents the creation of empty…
Andy
  • 23
  • 2
  • 7
0
votes
1 answer

WordPress postmeta table size, why base 64 encoded images removal from db didn't decrease the size?

I have a WordPress website, unfortunately the postmeta table size is increased to 25 GB, I was storing base 64 encoded images in the postmeta table as well In order to reduce postmeta table size, I have run a script and stored images in directory…
Smart Dev
  • 1
  • 1
0
votes
1 answer

Display custom post meta using a shortocde on WordPress

I have searched high and low and none of the solutions I have found have worked for me. I have created a custom post type call Testimonials and I have created two new custom post fields called testimonial-author and testimonial-company (these are…
0
votes
1 answer

Orphaned Postmeta Records in WordPress

This may sound like a ridiculous question, but I've seen a lot of weird stuff from WordPress plugins... I have about 105K orphan records in the postmeta table. As a general rule, can I assume that all orphaned records can be deleted? I have this…
IMTanuki
  • 117
  • 1
  • 9
0
votes
1 answer

INNER JOIN and multi-row data in SQL, wp_postmeta table

I am trying to make a report with different data from my WordPress tables. I would like to know which referencing has made how many views and display the phone number there. I already have all the data in my table, but I'm not doing it right for my…
Moerip
  • 61
  • 8
0
votes
1 answer

How to get the number of visits to an article in 24 hours?

I use this function to save article views function wpb_set_post_views($postID) { $count_key = 'wpb_post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; …
jimi-del
  • 93
  • 1
  • 11
0
votes
1 answer

Issue with WooCommerce too big database size especially post_meta

I have a Woocommerce site with around 10K products but got a 5.1 GiB database size and post_meta only occupy 4.5 GiB but the wp_posts table is 350 MB only. I have tried the following query but still not helping: **Deleting orphaned Post Meta in…