Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [get-post-meta]

This function returns the values of the custom fields with the specified key from the specified post. It is a wrapper for get_metadata('post'). To return all of the custom fields, see get_post_custom(). See also update_post_meta(), delete_post_meta() and add_post_meta().

0
votes
1answer
17 views

Adding Custom MetaData

In Professional Wordpress Design & Development the author states that WordPress features a simple function to add new post metadata called add_post_meta(). This function will attach a piece of ...
2
votes
2answers
60 views

loop through all meta keys with get_post_meta

I am building a custom solution where I am needing to obtain all the meta values for a post into an array. I have many "keys". Is there a way to loop through them all without doing this? I have the ...
0
votes
1answer
54 views

Allow HTML in Custom Metabox area

I know there are many questions related to my question, but sincerely i was unable to get solution. My question is simple, how can i allow html in textarea in custom metabox on post. So far i have ...
1
vote
1answer
48 views

WP-CLI How to generate a list of posts with corresponding meta values

I created this SQL query to generate a list of posts (which I will use for a CSV Sheet) SELECT p.ID, p.post_content, p.post_title, pm1.meta_value as 'Amazon.com', pm2.meta_value as 'Amazon.co.uk' ...
2
votes
2answers
347 views

How do I access post meta data when publishing a new post in Gutenberg?

I am updating one of my plugins for Gutenberg. I need to check for the presence of a custom post meta field when a post is updated or published, so I've hooked into publish_post: function ...
0
votes
1answer
87 views

get_post_meta not working on my custom-function page

I have saved the meta key with the name writer_meta_key and want to retrieve it on my custom-functions page. I can get it on front page and single page but it doesn't work on my custom-function page. ...
0
votes
0answers
71 views

get custom post meta inside custom taxonomy

Hello I create a taxonomy for one of my custom type and add meta field on the backend , I would like to display it in the front end , my code is currently: Could you help me ? /* Add Image Upload to ...
1
vote
0answers
22 views

Get User Post if Private

I'd like to display a message when current user's post is set to private. The code below does this, however only works when you are on the actual post page. I'd like for my message to be displayed ...
1
vote
1answer
74 views

Hide custom meta data if empty

I have a custom field created for WooCommerce products. I am using the below code to create // ADD CUSTOM WOO DATA add_action('woocommerce_product_options_general_product_data', '...
1
vote
1answer
23 views

Where to put meta Keys

Hello im creating my custom checkbox in gallery and i already add that , but save doesn't work , can someone take a look and tell me where should i put meta keys ? function wporg_add_custom_box() { $...
0
votes
0answers
38 views

Get meta values from parent post and save in child post

I have a custom post type "E-Books" with two categories "E-Book Title" and "Chapter Page", and custom meta boxes (table of contents, etc). The E-Book post type uses one page template, and displays ...
0
votes
0answers
20 views

Generate post content from meta fields

I have a custom post type (match). Each posts on this CPT has one ore more custom fields. Is it possible to automatic generate the 'post content' with the value of my custom fields on these posts? ...
0
votes
0answers
12 views

Is it possible to remove a conditional value from WordPress custom metabox

Here I have attached the screenshot from MySQL for easy understanding. In this meta value a: denotes total no of users liked the post. User denotes user with id user-id My question : Is it possible ...
0
votes
1answer
43 views

Reverse Cross-Sells (WooCommerce)

When you run get_post_meta( get_the_ID(), '_crosssell_ids',true); you get an array of all the products that the current product cross sells to. How do I reverse that? To get all the products that ...
0
votes
1answer
49 views

get_post_meta not working with variable as a post_id for dynamically get the postid

I would like to use the get_post_meta to pull a value from a CPT dynamically and then send a email. The problem is that the get_post_meta($post->ID, ... part of the code does not pull the email ...
0
votes
2answers
64 views

why get_post_meta is returning 0?

I'm trying to show all the posts on a page with an audio player in it and for that I'm looping through posts in the following manner: <?php $posts = get_posts(); $ID; foreach( $posts as $item) { ...
0
votes
1answer
62 views

copy images from custom field to another custom field

On my wordpress site I have a front end form that allows users to create posts and upload photos for a custom post type 'Property'. Using the following function - $property_sights_value = ...
0
votes
1answer
114 views

Custom Function to redirect singular post if specific meta field is empty

I have a custom post type People that has several metafields. When the ecpt_bio meta field is empty, the post will link to whatever URL is entered in the ecpt_website meta field on the post archive ...
0
votes
1answer
34 views

How to store multiple custom meta box

I am trying to store a multidimensional array of a Quiz where I dynamically add question box. But I am not able to figure out how to store dynamically added question box. The code is below function ...
1
vote
1answer
31 views

How to receive all the meta information of a post ?

How can I get all the meta information of a particular post_id, if my meta_key = 'title' and meta_value = 'My Content Template' meta_key = 'download_url' and meta_value = 'http://www.example.com/pdf/...
0
votes
1answer
47 views

ajax delete value from custom field array

I have on my page a multi file upload that saves post attachments within a custom field --- if (!empty($_FILES['vidPix']['tmp_name'][0])) { $i = 1; $files = $...
0
votes
1answer
90 views

Save attachment custom fields on front end

I have a front end post form that lets users upload multiple photos and on there I have 2 input fields to try and save custom meta data for each attachment - $vid_pix = get_post_meta($v_Id, 'vid_pix',...
1
vote
2answers
583 views

Display post metadata: “title, category, author, date” with shortcode

How to create shortcodes to the standard post-metadata "title, author, category and date" in order to display it in post-content? E.g. post-content including shorcodes: Lorem ipsum dolor [post_title]...
1
vote
2answers
55 views

What Wordpress function to use to get meta value by using meta keys?

This is the code: if ($keys = get_post_custom_keys()) { foreach ((array) $keys as $key) { $keyt = trim($key); if (is_protected_meta($keyt, 'post')) { continue; ...
0
votes
1answer
195 views

update_post_meta in loop changing ALL values

I have a button on the frontend that updates the value of post meta on the backend, and it's nested inside a loop. However, on submit it updates the value on ALL posts. What am I doing wrong? ...
1
vote
1answer
71 views

get_post_meta pagination

I have custom field, array with multiple values $metas = get_post_meta($post->ID, "$meta_key", false); foreach ( $metas as $metas ){ echo $metas; } Of course this will return an array. ...
0
votes
1answer
41 views

Print specific values stored in a post meta array

I'm triing to print some values stored in a post meta. My post meta_values looks like this : a:3:{s:6:"amount";s:117:"€2.00";s:6:"entity";s:5:"11854";s:9:"reference";s:9:"800146779";} I'm ...
0
votes
1answer
96 views

Easy Image Gallery - Retrieve Serialized Data

I am using Easy Image Gallery. It is called: _easy_image_gallery and looks like it's an array like 1234,5432,2345,..... Now, Easy Image Gallery update to 1.3 is saving into a meta called: ...
2
votes
0answers
219 views

get_post_meta returning empty string when data shows in the database

I'm absolutely stumped and I'm hoping this is something stupid that I just can't see because I'm too close to it. Working on an LMS using Sensei. Trying to get the course_id from a lesson. Pretty ...
1
vote
2answers
94 views

get_post_metadata() undefined when used in loop in RSS template

I understand how to use get_post_metadata(), however this code in a custom RSS feed template: while( have_posts()) : the_post(); // Has a custom URL been supplied? Use that in preference. $...
0
votes
1answer
55 views

Add custom field information to source meta data

I try to add information from a custom field into the metadata in the source code. While searching for the solutions I found some. As I am not really an expert I ask you guys. I want to add ...
1
vote
0answers
25 views

delete all post with certain meta_keys

I'm currently trying to delete metakeys once my plugin is uninstalled to keep the database clean. My code is as follows: Array of meta_keys that are created $keys = array ( '_menu_item_icon', ...
1
vote
1answer
54 views

Can't access post meta on new post creation (cpt)

I'm using... function on_CPT_request_publish( $new, $old, $post ) { // ----------------- Start of Function ----------------- if ( ( $new == 'publish' ) && ( $old != 'publish' ) && (...
-1
votes
1answer
41 views

Documentation for post meta

Trying to solve this problem I tried to find the complete list of all available/possible default "post meta" tags/entries. I couldn't find this info documented anywhere. Any pointers?
-1
votes
1answer
260 views

Save meta data with post, Without using any plugin [closed]

I have a post type in which I need to save price with each item. Please, suggest how can I create meta-field in my post type, without using any plugin?
-1
votes
2answers
248 views

How do i output images from URL's added to the same custom field key

This is my array of image URL's added to the same custom field named images. $images = get_post_custom_values( 'images' ); I need to print all these images in a template file.
0
votes
1answer
192 views

Using Self Hosted Video URL With Custom Fields

Can't get this to work with a self hosted video URL added to a custom field. function video() { $self_hosted = get_post_meta( get_the_ID(), 'self_hosted', true ); $video_self_hosted ...
0
votes
2answers
156 views

Check for custom field value in different post type than current one and do something

I have 2 post types, one is for my posts and the other one is used as a submission form. When a user is on a single post page for post type A, I am trying to do several checks to then display ...
0
votes
1answer
362 views

Get value from an input field and pass into update_meta_data as $meta_value

I am building a woocommerce site and I have some input fields the on the product page. one is for recipient email (its for a gift car). Everything works, and the recipient email is saved on the order, ...
0
votes
0answers
298 views

Save, update, get and sanitize post meta as HTML not plain

My post meta always is plain text HTML striped from it I need to Save, update, get and sanitize post meta as HTML not plain here is all my related code to this post meta filed Retrieve from ...
1
vote
1answer
343 views

Are multiple values from get_post_meta guaranteed to be ordered?

You can create multiple rows in the postmeta table for a post with the same key, like this: add_post_meta( $post_id, "example_key", "value1" ); add_post_meta( $post_id, "example_key", "value2" ); To ...
0
votes
0answers
24 views

How to get post that has non zero or greater than zero meta value

How to get post that has non zero or greater than zero meta value $args = array( 'sort_order' => 'asc', 'sort_column' => 'post_title', 'hierarchical' => 1, 'exclude' => '', 'include' =>...
0
votes
1answer
203 views

get_post_meta producing white screen of death

I’m using Divi, and added the following code below the post content in single.php: <?php if(get_post_meta($post->ID, 'store-url', true) !== '') { ?> <div class="store"><a href="&...
0
votes
1answer
53 views

How i can extract data

Hello i have form with nested repeater field, all data in nested repeater group saving in database like this: a:6:{i:0;a:4:{s:5:"title";s:21:"Initial ";s:11:"description";s:78:"Please show identify.";}...
1
vote
1answer
726 views

Header: Include Date Published and Date Modified

I'm trying to put the Date Published and Date Modified into the meta tags of the head of the header.php page - so far no luck. This is what I currently have: <meta name="date" content="<?php ...
1
vote
1answer
311 views

How to create a shortcode to print specific values stored in a post meta array?

i am having problems printing a specific value stored in a post-meta array in a WordPress loop created by a Visual Composer Grid Builder, thru a shortcode (i also tried the grid builder Custom Field, ...
0
votes
2answers
80 views

Data not displaying in text field

I have been working on trying to get data to store and display on a CPT field. The code I have is here: function fhaac_subject_box_callback( $post ){ wp_nonce_field( basename(__FILE__ ), '...
0
votes
1answer
2k views

Submitting Custom Post Types with custom fields from Front-end form

I'm trying to have a custom type post with 2 custom fields. Now I have the working custom post types and working form at the front-end via a template page. The problem is I can not get the custom ...
0
votes
1answer
568 views

How to show custom field on specific custom post type posts only when filled

On my demo website i would like to show some custom fields on posts of specific custom post type. And if possible only when they have a filled in value. Demo site: http://www.jsfaber.nl/gibson-eb-2014-...
0
votes
1answer
181 views

How to extract data from a post meta

What is the best way to extract the information from the database using get_post_meta? field name = invoice_details value = a:20:{s:15:"price_per_night";s:3:"150";s:12:"no_of_nights";s:1:"1";s:23:"...