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
0
votes
1 answer

Display user role name within WooCommerce API

I am looking to display user roles when issuing a GET request e.g: https://yourdomain.com/wp-json/wc/v3/orders. The end goal is to use the user roles as a unique identifier in order to separate orders within an ERP based on the user role. Any ideas?
Qwerty
  • 3
  • 1
0
votes
1 answer

Query select in table with double WHERE condition (WordPress wp_postmeta table)

I am trying to extract multiple IDs from wp_postmeta table, with double WHERE condition to be checked in two records: WHERE (meta_key = 'leather' AND meta_value = 'calf') -> First record AND WHERE (meta_key = 'gender' AND meta_value = 'woman') ->…
0
votes
0 answers

WP: Trying to update associative array in post_meta with AJAX call

I'm cycling through an associative array and adding each child array as a row in a table. The last column in that table is a button in which I want to use to remove that array from the parent array in the database. Here's my…
Eric Brockman
  • 824
  • 2
  • 10
  • 37
0
votes
0 answers

unserialize() php function not converting when I put folder address instead URL

I am inserting post meta into database using wordpress, the field I want to insert is video url but sometimes I insert video folder address from my windows. the way they are inserted is like this: s:162:"a:1: {i:0;a:5: {s:4:"type"; …
0
votes
1 answer

get_post_meta shortcode returns empty field

I'm trying to create a custom shortcode that will allow me to input custom order field data into an auto generated outbound email template via the Custom Order Status for WooCommerce plugin. My understanding of PHP is limited at best but I came up…
rabiancone
  • 71
  • 5
0
votes
2 answers

Problem with add_post_meta() function in Wordpress

When a use it like this: add_post_meta($post_ID, 'Name', "Bob", true ); works fine, but when a store an string value inside a variable, for example: $name = "Bob"; add_post_meta($post_ID, 'Name', $name, true ); // <---- This doesn't work. Some…
0
votes
0 answers

Change Post meta based on user role

I cannot find a solution to this WordPress problem: I have multiple user roles that all can submit front end posts that were created with custom post types. I would like to change the user's submitted post's taxonomy based on the upgraded/downgraded…
DaveHil
  • 3
  • 2
0
votes
1 answer

Query in Wordpress of a Custom Post Type with the postmeta

I am trying to make a wordpress shortcode with a query. I have to make a query of how many orders were made of the products in the last day and in the last week. I don't know how to filter by date (the date is also in text format). Thank you very…
EmanuelAA
  • 11
  • 4
0
votes
1 answer

MySQL Database Size Limit Exceeded

My hosting company only allows 1GB per database. There is a table in my database, wpas_postmeta, and it is 3.6 GB. Any suggestions on how I would go about on deleting some of this data without affecting my WordPress website.
0
votes
0 answers

WooCommerce Loop through product's custom post_meta

So basically I am trying to loop through custom post meta, that I added to the CSV Import Excel File via Custom Header Reference ( e.g meta:Temperatur ). When I output all of the post_meta I see that my added custom meta is added…
0
votes
1 answer

How to extract data from WordPress's wp_postmeta table?

I have a WordPress website when some user fills in the form I want to find 3 users nearest to him and send them an email. I don't think it's possible with WordPress without editing the theme and I don't have much experience with WordPress. So I…
jixodoj
  • 179
  • 2
  • 11
0
votes
1 answer

Combine Similar Strings Value into Unique One

I'm fetching a post meta from Wordpress CPT which's returning multiple strings form individually instead of array as shown below: $data = $calendar->data(); foreach ($data as $event) { $days = get_post_meta( $event->ID, 'sp_day', true ); …
David Buik
  • 522
  • 1
  • 8
  • 31
0
votes
2 answers

Update meta feild for "Elementor" _elementor_data in admin

I am trying to update url in elementor data. $metacontent = get_post_meta($idforupdate, '_elementor_data',true); $with_slash = stripslashes_deep($metacontent); $with_slash = str_replace($value, $url_1, $with_slash); $metacontent1 = str_replace("/",…
Kashif Munir
  • 193
  • 1
  • 3
  • 19
0
votes
0 answers

Why $wpdb works on localhost but it is not working on server

I am building a plugin in WordPress and $wpdb queries works on local, but when I upload the code to the server it doesn't work. Here is the code that I'm using: get_results( $wpdb->prepare( …
0
votes
1 answer

Change Wordpress content field with php

On a project of mine, i work with ACF (advanced custom fields), but due to some restrictions i can't just output the ACF, i need to get the output into the wordpress content field. I actually have a solution that works, but it also brings some…
Phpnewb
  • 127
  • 1
  • 9