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().

Filter by
Sorted by
Tagged with
1
vote
2answers
59 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
206 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
77 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
47 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 ...
1
vote
1answer
318 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
1answer
102 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: ...
0
votes
2answers
1k views

User function to return multiple get_post_meta()

I am trying pass a WP function to a user function, where I can pass a new func argument $key for each post_meta type here: functions.php function my_post_meta($key){ $meta = get_post_meta($...
0
votes
1answer
287 views

Is it possible to set a variable for get_post_meta?

I have a lot of places within my templates where I get custom post meta set up with CMB2 and I was wondering if it's possible to set get_post_meta( get_the_ID() ) to a variable like $service_meta = ...
1
vote
1answer
449 views

Get Meta Key Value While Saving Post

I am trying to insert meta key value while saving or updating post but somehow it is not inserting meta value to link column of my custom talbe called wp_banner_views function get_publishing_id($...
1
vote
2answers
99 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
0answers
829 views

loop through custom post types with meta data

I'm really curious as to how might be the quickest way to loop through a custom post type with meta data. I have some code that works but it's slow. I'm using wp_query and it works. I have also a ...
2
votes
0answers
226 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 ...
0
votes
1answer
58 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
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?
3
votes
1answer
3k views

get_post_meta() unserialize issue - returns boolean(false)

I'm using a simple custom plugin that parses and saves external XML data as a serialized array in a custom field. This works fine, however, when I update the post, instead of the array I only see a ...
0
votes
1answer
1k views

Get the correct meta_value with get_post_meta

I tried using the function get_post_meta() to get the meta values of my posts. However to my surprise it returns an Array that contains again arrays! So I looked inside the second level array, and was ...
-1
votes
1answer
314 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
261 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
203 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
5answers
6k views

Get YouTube video id from url in a custom field

Here's the scenario, I have a site with thousands of YouTube video posts which are stored in a custom field 'video_url' which is being used in a custom video player. The custom player I'm using now ...
0
votes
3answers
4k views

Get $post->ID from a URL

I have a custom post type called music. I have created a custom template as a normal page to show some stats for the musicians. I have a page where they can see all their songs and have added a stats ...
0
votes
2answers
188 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 ...
9
votes
3answers
15k views

How to get custom post meta using REST API

I am trying to create a REST APIs for my wordpress website which is used for facility listing using wordpress job manager plugin. I have registered my custom post , taxonomies in \plugins\rest-api\...
0
votes
1answer
379 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
317 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 ...
0
votes
3answers
1k views

get_post_meta fields don't show up on posts page

I'm new here, and to coding! I've been working hard (so, so hard...so hard) to create my website and with occasional help I've created a look and feel I like using some custom get_post_meta fields for ...
0
votes
1answer
1k views

Show value of select dropdown in meta box

I have created a meta box which has a select dropdown list and i want to show it in the post as a user selects a particular option from meta box.I cant figure it out how its done.Here is my meta box ...
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
211 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
54 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
760 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 ...
0
votes
2answers
82 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
598 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-...
1
vote
1answer
670 views

get_post_meta not working on category.php

I'm referencing an attached image in my header.php page which is displayed as a full screen background on my posts: global $wp_query; $page_id = $wp_query->get_queried_object_id(); $...
0
votes
1answer
194 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:"...
0
votes
1answer
625 views

get posts meta query returning the latest post if no meta key found

I have this pretty standard script that looks for a preview or a report (custom post types) which have data stored against them (serialized array) taking the form of a guid. The guid is present on ...
2
votes
1answer
3k views

get_post_meta returns bool(false)

I've been testing and trying to find where it possibly going wrong but i'm stuck on that part. The get_post_meta() is not returning any of my values, tested with a var_dump(get_post_meta(1)) this ...
1
vote
1answer
529 views

How can I get my iFrame to work with url from post_meta?

I've made a custom meta box for adding an URL to the post, which can be displayed later on the frontend page. This url is inserted in my database correctly. Then I'm getting the url in my code by: &...
0
votes
1answer
91 views

do_shortcode based on _thumbnail_id

Situation I've created a Custom Post Type called 'Banners'. On each post I'm able to add a featured image. This will be saved in my database and will get an _thumbnail_id. Also on each post edit page, ...
2
votes
1answer
181 views

Meta tags in shortcode

The thumbnail and title shows up as it should, but the post meta displays on the top of the page. What is the correct code for retrieve the post metadata? function evasmat_posts_shortcode(){ $q =...
1
vote
0answers
283 views

Run Shortcode of post's custom field in functions.php / Plugin

After 3 or 4 hours of searching the web for a solution, I abandoned it and hopefully you can help me? I added a sub-headline as a custom field (subheadlineclass). That works pretty. I can save, edit ...
0
votes
1answer
173 views

Unable to get specific value from post meta

I am using get_post_meta() to retrieve a custom meta field value from a given post. The custom meta box has a parent checkbox which has 3 child checkboxes. I want to get the values of both parent and ...
0
votes
1answer
237 views

Sending mail not working correctly

SITUATION I have a reserve system for a restaurant and I'm trying to send data out of my wpdb to myself with the mail() function around 3pm. So I get a overview of all the reservations for the current ...
0
votes
0answers
127 views

How to get a post meta value and pass that to update_option when a post is created or updated?

When a user publishes or updates a post I want to get a post meta value from that post itself. Then I want to use update_option() to pass that value into the get_option() name. I've been trying ...
-2
votes
5answers
3k views

Problem with get_post_meta

I am using this code to retrieve post meta: if ( get_post_meta($post->ID,'a',true) == '') { echo '<img src="' . get_bloginfo( 'template_url' ) . '/img/img22.jpg" ></img>'; } else {...
0
votes
2answers
44 views

Link image with data from the wpdb

It might be a stupid question, but I can't get it to work.. Problem I have no idea how to link my image on the frontend with the url from the database. Situation I've created a Custom Post Type ...
0
votes
1answer
375 views

undesrtanding get_post_meta function

Is there any way to avoid that when you don’t specify a $key ('') and set $single to true in get_post_meta, it returns all keys still with an array of values, instead of returning a single value only ....
1
vote
2answers
1k views

Display custom post type from dynamic custom field

I am trying to create a custom meta box that lets you add rows dynamically. Following code snippet works fine and and saves data in my edit page section. However, I can't get it to display the data on ...