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

set post per page using get_post_meta

I have code to show get_meta_post per page this my code if ( have_posts() ) : while ( have_posts() ) : the_post(); $metas = get_post_meta(get_the_ID(),'value_gallery',false); //var_dump($metas); ==> will output array(1) { [0]=> string(29)…
jack
  • 109
  • 14
0
votes
2 answers

How to Show Total Post Views of User in WordPress community theme?

So, here I am using Boombox Theme for my community website and I wanna show "Total post reads/views" from a user, for example an A user has 10 post and has various views each post, I need the total view from all of A's post. is it possible to do it…
0
votes
2 answers

Debounce Wordpress action hook (or any other PHP function)

I have a Wordpress plugin which sends post data after a post/postmeta change occurs. The problem is that there can be very many postmeta changes on a busy Wordpress site, so I'd like to debounce/throttle/aggregate the meta updates to a single POST…
steakoverflow
  • 1,206
  • 2
  • 15
  • 24
0
votes
1 answer

Same query. Same dataset. Two MySQL servers. TWO DIFFERENT RESULTS. Why?

Same exact query. Same exact dataset. Two different MySQL servers. TWO DIFFERENT RESULTS. Why? Query: SELECT DISTINCT term_taxonomy_id FROM ( SELECT * FROM azEw_term_relationships WHERE `term_taxonomy_id` IN (SELECT term_taxonomy_id FROM…
Slam
  • 3,125
  • 1
  • 15
  • 24
0
votes
0 answers

Creating sql query that references a meta value

Hoping for some help with a sql query. I have the following: $sql = "SELECT * from (SELECT m1.post_id as ID,post_date,m1.meta_value as project_name, m2.meta_value as access_key, m3.meta_value as seq_number FROM wpha_posts join wpha_postmeta m1 on…
mischiefbec
  • 51
  • 1
  • 8
0
votes
2 answers

Execute PHP code once per week in a Wordpress single.php template

I have the below code in my single.php template. It retrieves a price from an external website, then, if it's different than the existing price custom field, it updates the meta value. That part works as intended. What I'd like to do, though, is…
0
votes
0 answers

How can I automatically link words in post meta data and the_content to post titles?

I'm trying to create a glossary for my WordPress site, using a custom post type 'glossary'. My idea is to create posts for each term/word I want to explain (for example: 'blepharoplasty'), and use the content of the post to provide a…
Lee
  • 4,187
  • 6
  • 25
  • 71
0
votes
1 answer

WordPress insert IP address as post meta using PHP and ajax

I'm using AJAX, why I can't insert IP address as post meta $User_IP = $_SERVER['REMOTE_ADDR']; it always insert the database like this ::1? My code: function setFilmLikeUser($postID) { $count_key = 'add_film_like_user'; $count =…
0
votes
1 answer

How can I get_posts if the post ID is in an array of a custom meta?

I'm adding custom meta to my attachment files, and want to store three page IDs per attachment in an array. Then, I want to do a get_posts for attachments whos ID exist in this array, but the array is being returned as empty. $p_downloads =…
Lee
  • 4,187
  • 6
  • 25
  • 71
0
votes
1 answer

Wp meta value for dropdown box in custom post

I have added one custom post in admin side for adding session details.Inside session post i want to add a speaker data by using dropdown box.but the data is stored in the post meta as "a:2:{i:0;s:2:"91";i:1;s:3:"105";}" Here 91 and 105 are the ID's…
Reshma
  • 189
  • 2
  • 5
  • 18
0
votes
2 answers

Wordpress query custom meta key

I've added a postmeta (popular_posts) see image below. But when I query posts with meta key "popular_posts" like in below I've had no result: new WP_Query(array( 'meta_key'=>'popular_posts' )) Some one can explain me how to properly retrieve that…
Zozo Zozo
  • 141
  • 4
  • 4
  • 12
0
votes
1 answer

How to update post meta data with multiple values

I have an array I am looping through and each loop I figured it would either update or add to the database so I could have multiple product IDs in the postmeta table but it only adds the last one and overrides all the other values. Is there a way to…
Nick
  • 1,036
  • 2
  • 14
  • 27
0
votes
0 answers

Wordpress add_post_meta with increment

I need to add incrementing id only for published posts. I try to make it when saving posts with add_post_meta function. But it always returns 1. add_action('publish_post', 'add_program_id_automatically'); function…
www
  • 35
  • 7
0
votes
1 answer

Custom Post Type rating not working

Using the following code I managaed to add Rating to my custom post_type and I intend to show star signs according to number of rating: function display_game_meta_box( $game ) { // Retrieve current name of the Author and Game Rating based on…
Sidney Sousa
  • 3,378
  • 11
  • 48
  • 99
0
votes
1 answer

WP How can i save a comma format number in a meta field

I have added a custom field to the post Editor to save a temperature as number value. If i put for example "15,2" or "15.2" in this field and save the post, its get saved as "152". How can i fix it? Form Field:
Mariano Schmands
  • 732
  • 1
  • 6
  • 18