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

learn more… | top users | synonyms

0
votes
1answer
483 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 ...
4
votes
1answer
38 views

Check if user already visited this post today

I have a piece of code which measures a post popularity. How would I go about checking if user didn't already visited this post for past 24 hours? Do I need to set a cookie for user and for each post ...
1
vote
1answer
713 views

get_post_meta unserialize issue - retuns 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 ...
3
votes
2answers
49 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 ...
1
vote
1answer
24 views

Populate dropdown from one custom post type inside another custom post type

[Solved -> see last comment in this question] In custom post type CPT_A I am saving first_name and last_name via a custom metabox form field (they are not taxonomies): update_post_meta( $post_id, ...
0
votes
1answer
37 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 ...
0
votes
2answers
169 views

String taken from database table post_meta is showing HTML tags on Frontend

I have saved a string in post_meta table in wordpress database with html entities like- <p>Hello <b>Shashank</b>, I have an idea.</p> When I get this string on frontend using ...
0
votes
1answer
22 views

Saved Post Meta Array Returns as String

I am saving an array in post meta using update_post_meta. $arr = array('this', 'or that'); update_post_meta($post_id, 'field', $arr); $ret_arr = get_post_meta($post_id, 'field', true); ...
0
votes
1answer
156 views

get_post_meta($post->ID) returns empty string when in preview mode of custom post type

I've got my custom post type 'event'. I got tne next code in single-event.php: get_header(); the_post(); echo '<pre>'; echo "$post->ID\n"; var_dump(get_post_meta($post->ID)); echo ...
0
votes
1answer
532 views

Display an icon with get_post_meta?

I want to display an icon in the post meta data in the loop.php, for each post have a specific meta_value! To be more specific i use this code to display an icon when a new posts has been published ...
0
votes
0answers
34 views

wp_get_post_terms returns empty array

So I have a Post term called JobNumbers, which holds jobnumbers per page. I then enter into the DB a count per page/jobnumber. This has historically been working, but something happened and now it's ...
0
votes
1answer
33 views

Query Multiple meta

Hi i've looked through the forum but can't seem to find the right solution to what i'm looking what we have is a property website and have various pages setup to show specific types of properties ...
0
votes
1answer
58 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 ...
0
votes
2answers
25 views

WP_Query with child element

I have my calendar events, I want to sort them by creation date with the query, but here's the issue: I have a meta key which has child values: First one is $data = ...
3
votes
1answer
56 views

Add options to featured image

I want to add an option to the featured image metabox. I have found a way to do this here The problem I'm having is saving the value tot the database. Here is what I have tried: add_filter( ...
0
votes
1answer
591 views

Dynamically get the meta key value of a menu item based on it's post ID

I have a menu, that I need to insert an image that have it's path saved in a meta key (_menu_item_img) and associated with a post ID, every menu entry has it's own image, and I need to grab it ...
1
vote
1answer
49 views

Meta Key Value in current-user-only loop

I created a loop for logged-in-users-only which works perfectly for all data except for meta keys. I'd like to be able to also extract meta keys but had no luck so far. This is my loop (based on this ...
0
votes
1answer
62 views

get_post_meta returning broken path in image src

I am using a custom field to store the path to an image and then using get_post_meta() to insert that path into an <img> Here is my code: <img src"<?php echo get_post_meta( get_the_ID(), ...
0
votes
0answers
19 views

how to display meta box data on page?

i have this function in my function.php and i am trying to display the meta box data on my page. Can not do so. function designation_meta_box($post){ wp_nonce_field( ...
0
votes
2answers
218 views

Why is get_post_meta returning an array when I specify it as single?

The documentation from get_post_meta makes it sound as if the single argument will determine whether or not meta values are returned in an array or not. For example: // If I set single to false, or ...
0
votes
1answer
108 views

How to use json_decode a post_meta value? [duplicate]

I have used get_post_meta($post->ID) to get all custom fields for my post since I have many of htem. Some of them were checkbox values and var_dumping the variable gives me this array (size=1) 0 ...
0
votes
1answer
32 views

Plugin Shortcode value in post

Theme was output with function get_post_meta(get_the_ID(), 'some_value', true); when I try with die(print_r()); function there have some array containing values such as [item_ticket_tailor] => ...
0
votes
4answers
2k 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 ...
1
vote
0answers
47 views

Default Custom Field Value Automatically Update

I have created a hidden custom field with a php function as its value. Like so -- $value_rating = get_post_meta($Property_Id, 'vr', true); <input type="hidden" name="vr" class="form-control ...
0
votes
1answer
37 views

get_post_meta with related user

When I call post with get_post_meta I get all posts.I would like to get related post from user when using get_post_meta. How would I achieve this? Example: If I am logged in as foo than I would like ...
0
votes
1answer
70 views

get_post_meta with variable

I’ve created a custom post type and a corresponding meta box for a site I’m developing. As there are several entries for similar 'products', some of the post metas repeat, albeit with a trailing ...
0
votes
1answer
51 views

Order a WP_Query by meta value where the value is an array

I have a WordPress custom query: $args = array( 'posts_per_page' => 2, 'meta_key' => 'pworks_popular_posts', 'paged' => $page_nr ); $query = new WP_Query($args); ...
0
votes
1answer
27 views

Get post_meta from specific post [closed]

I'm trying to get the post_meta from a specific post. However: the following code breaks my document: $img= get_post_meta('4996','ATHLETE-side_img'; Then further down in the code I was planning ...
1
vote
3answers
269 views

Why does get_post_meta not work with the posts page?

Looking for a reason why get_post_meta() doesn't work with home.php. From my reading I understand that it's a template and not a post or page, per "Custom fields won't display on my blog page". The ...
0
votes
0answers
36 views

Display post_meta-by_key on product catalogue

I'm trying to display a custom field in my woocommerce bookshop catalogue. I have added the field "author" and I want to display it after the product title, and before the price. ...
0
votes
4answers
926 views

How to Echo Metadata Value in Currency Format

I have a Custom Post Type with a Metabox and an input Text field for adding "Price" to the posts. Now I would like to display the input value which can be like 49 or 59 like 49.00 or 59.00 so far I ...
0
votes
3answers
129 views

Get array of metakey in all posts

My posts contain a meta-field that holds an external id. I'm trying to create a function with a loop that goes through all posts and puts all the meta-keys in an array and returns this array. This ...
0
votes
0answers
108 views

Dynamically add text-field to a custom post

I have created a custom post called 'schedule'. In that I want a button, when user clicks on that new text-field should get added with name and all text field should have a same name.Also help me how ...
0
votes
1answer
22 views

CPT posts in drop downed in meta box on page doesn't return post ID

I have an issue with displaying ID of selected post. Could you guys help? thanks Function below add_action( 'add_meta_boxes', 'cd_meta_box_add' ); function cd_meta_box_add() { add_meta_box( ...
1
vote
1answer
185 views

get_post_meta causes database queries

I want to know why my site's search results are slow. I've used the excellent Debug Bar plugin, and found out that each search result causes 5 DB queries, of which 3 are SELECT meta_key (see below for ...
1
vote
1answer
483 views

Create a random unique 6 digit number as custom field for custom post type

I use the following function to create a random unique 6 digit number and save it in a custom post type meta field. I am unsure about the use of rewind_posts() inside a while loop. The idea is that ...
0
votes
3answers
2k views

get_post_meta in WP_Query

I'm doing a plugin to add likes to posts I want to create a table on a page in the plugin to show each post and the number of likes function my_plugin_options() { echo '<p>Table of ...
0
votes
0answers
85 views

How to get meta value based on latest post id with group by term name

my query is SELECT terms.name as artist_name, wposts.ID,wpostmeta1.meta_value as image FROM wp_posts wposts LEFT JOIN wp_postmeta wpostmeta1 ON wposts.ID = wpostmeta1.post_id and ...
2
votes
1answer
182 views

How to hide meta box values from custom fields list?

I have created a metabox : function drama_description_metabox_markup() { global $post; $drama_description_metabox_markup = get_post_meta( $post->ID, 'drama_description', true ); ?> ...
0
votes
1answer
160 views

Meta box data is saved but NOT displayed in the meta box text field. Why?

I have a custom post type and I created it using the following code. /* DRAMAS */ register_post_type('dramas', array( 'label' => 'Dramas', 'show_ui' => true, 'supports' => ...
0
votes
1answer
98 views

How to call a post's metadata in shortcode.php?

I'm not a terribly advanced WordPress developer, but I can kind of futz my way into a solution most of the time. This time, no such luck: I'm trying to write a shortcode to display a custom post type ...
0
votes
0answers
72 views

How can I get the $key / $value pairs of custom fields that were added via 3rd party plugins or themes?

I'm running WP Job Manager plugin which is designed to allow its custom post type fields to be altered within a theme or plugin via custom filters. I have added my own custom fields (example) and the ...
-1
votes
1answer
101 views

Access post meta just after publishing

the following code is supposed to store post meta of the recently published post to the variable $temp. But it doesn't, $temp is always empty. This seems to happen because "transition_post_status" ...
-1
votes
1answer
44 views

Automatically add custom taxonomy when meta value gets to a set number or beyond

Is it possible to add a custom taxonomy to a post when a meta value gets to a set number? Im trying to get it so once my post_views_count gets to 150+ it then gets the custom taxonomy trending added ...
0
votes
4answers
192 views

Remove href tag from wp_postmeta in 34,000 posts?

I'm using Godaddy Hosting, PHP 5, and Wordpress 4.2.1 I have 34,000 + posts that need outdated href tags removed. I am able to remove tags, one post at a time, by using this code in a page template ...
0
votes
1answer
136 views

Display Data From This Custom Media Upload Meta Box?

This plugin is working without any issue on CMS. Now I need to know how to properly display them in my post. Custom Media Upload Meta Box Plugin. $meta_box_media_upload = new ...
0
votes
1answer
90 views

Display post meta conditionally based on it's value

I have a custom field that's a radio button with 3 choices (yes, no, other). What I'd like to do is the following: [If custom field value is yes] Display something here [elseIf custom field value ...
0
votes
0answers
93 views

global $post object contains the wrong post

I'm using Bridge theme from QodeInteractive. This morning, all of a sudden, all my preferences from a page were gone. Preferences are saved as meta to the corresponding page. On debugging, I found ...
0
votes
2answers
636 views

how to get a list of meta data fields assocaited with a custom post type

I am using a theme which has defined a custom post type-- Now, I am trying to retrieve the list of metadata fields used by that post type-- so that I can insert data via PHP code in form of that ...
0
votes
1answer
677 views

get_post_meta not extracting title,permalink and posttype

i need to extract the post_type, title of the post and the permalink using get_post_meta i am trying following code for the same $title=get_post_meta($post_id,'title',true); ...