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

Check for update in wp_posts or wp_postmeta tables

I have a WordPress website and have a page which shows all WordPress posts. Now I refresh the page every minute with javascript. But it is kind of annoying because I want it only to refresh when there is a update in the wp_posts or wp_postmeta…
GrLTCode
  • 35
  • 6
0
votes
1 answer

How to store Gutenberg ColourPicker RGBA as metadata (React)

I'm trying to build a sidebar plugin for Gutenberg which uses the ColorPicker component to store a chosen rgba value in metadata using withSelect and withDispatch (I'm testing below with the hex value). The plugin is generally working as it should;…
0
votes
2 answers

Wordpress display posts from multiple value in meta

I have got main product with meta key: addons and meta values in this key: 129456,968945,495435 Each of these three numbers is the key with these meta values. For example: Post 1: meta_key: subproduct meta_value: 129456 Post 2: meta_key: subproduct…
Tom Harisond
  • 57
  • 1
  • 10
0
votes
0 answers

Replace 'Attribute' with custom field (post-meta) value in a script that is working ( Woocommerce )

This should be fairly straight forward but I keep getting "Internal Server Error" when trying to swap the custom field value with the attribute value. Below I have 2 workings functions... The first is a function that adds a custom field into a…
0
votes
2 answers

How to update WordPress post_meta dynamically

I am trying to insert/update post meta when the user registers. Before writing that action, I am testing this code on the page so whenever the page refresh it will insert/update the post meta. Question: However, the below code is not…
Code Lover
  • 8,099
  • 20
  • 84
  • 154
0
votes
1 answer

add_post_meta for all custom posts that dont have the metakey yet

For custom post type "bedrijf", i created a possibility where visitors can leave a rating. If they do, the meta key and value is added and saved. If there is more than one, the average is calculated and the value field is updated. However, most…
Webdever
  • 485
  • 5
  • 17
0
votes
1 answer

WooCommerce not saving post meta value

In my WooCommerce site i have create a product and in this product i have attached a lot of pdf files so that after user buy it he can download all these pdf files but the problem is that in this product i have more than 375 files so after added 320…
Deepak Goyal
  • 1,186
  • 2
  • 13
  • 26
0
votes
2 answers

How to get values of custom meta field of multiple arrays

I try to get a list for all posts of custom post type bedrijf from all values of a custom field. This field is an array of values. However, when I try to output the custom fields, I get Notice: Array to string conversion in ... I have tried…
Webdever
  • 485
  • 5
  • 17
0
votes
1 answer

WP Metabox not saving post meta

i am trying to implement a simple checkbox on the page, in order to dynamically add a Html chunk in case the user choses it, but i am unable to save the post_meta to perform this task, can someone help me? The value taken from this checkbox input is…
Luiz Wynne
  • 460
  • 3
  • 10
  • 28
0
votes
1 answer

Wordpress post update not updating postmeta by wordpress hook

I want to update postmeta value for a post by wordpess hook but i am not able to update it. Here is my code, function check_values($post_ID, $post_after, $post_before){ $oldFob = get_post_meta( $post_ID, 'price', true); if($oldFob){ …
Maha Dev
  • 3,915
  • 2
  • 31
  • 50
0
votes
2 answers

Illegal string offset on meta value === 1

I want o display post from custom post after checking if the meta key value of the post is === 1. But I get an error "legal string offset 'isAirConditioning'". What did I do wrong? I have created a custom post called "Works". To this custom post I…
Dariusz
  • 193
  • 1
  • 12
0
votes
0 answers

Inserting special characters into WordPress postmeta

We are trying to retrieve HTML code stored as a LONGTEXT in an UTF8 MySQL table then store this as a post meta value in WordPress. If the HTML contains a pound (£) symbol for example then the ‘update_post_meta’ function does not store data …
0
votes
0 answers

Change date format FacetWP

If I filter on date range in FacetWP plugin for Wordpress. I outputs the URL like 2018-11-29 but I want it to output the date without '-'. So it is gonna be 20181129. Does someone know how to achieve this?
JGR
  • 39
  • 7
0
votes
2 answers

WP MetaQuery with ACF nested fields

Okay so I need to get all posts to which the current post is related to. This is set through a relationship field on the queried posts, not on my current one. But the quirk is that the relationship field is nested within a repeater field for…
0
votes
1 answer

Wordpress Add, Update and Get Post Meta not working

The below code is added into a page template file, when someone loads the page it will add the post meta if it didn't exist, it will update the post meta if it did exist. When I get the post meta and then return it, the outcome is "Array". It leads…
Daniel Vickers
  • 1,054
  • 1
  • 12
  • 32