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
0answers
20 views

Very slow query for getting posts with postmeta

I have an heavy query generated by an search page which should get filtered posts based on some meta data. SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON ( ...
0
votes
1answer
21 views

add_post_meta doesn't work

I tried this on localhost and it worked, but then I tried to run this on live server (the same template, everything) and it doesn't work. Any help? add_post_meta('39', 'overall', '4');
1
vote
1answer
37 views

Why is my Custom Meta Box Field Inputs NOT saving?

I have a custom post type labelled 'web_design' and I want my 'web_design' posts to have the following custom fields: 1. 'client' - Client Name 2. 'exlink' - External Link 3. 'datefin' - Date Finished ...
-1
votes
1answer
26 views

How to match data in multidimensional array of post_meta_data?

I am saving user id in post meta whenever someone clicks on like button. $voter = Array( voter => array( 'post_id' => $post_id, ...
0
votes
0answers
16 views

Issue with temporary link on the frontend

I have a site working with a custom post type (Exhibition), and custom taxonomies (Exhibitions -> Current, Future & Past). When I display the archives for the Future and Past taxonomy values, it ...
0
votes
1answer
25 views

Get all terms linked to a post and include those who not connected from get_terms and sort

I have the following terms in my WordPress project and my post may have connected with some of them or sometimes all terms. A B C D E F My first post (example1) is connected with terms A, B and C ...
0
votes
1answer
34 views

Display posts with empty custom field

How to list post with specific custom field which is empty? I have some posts with custom field 'author', and for some posts that custom field is emty, so I would like to find those posts to delete ...
0
votes
2answers
33 views

Cannot obtain custom meta information

I'm trying to access custom meta data from a custom post type called 'Videos' The following code is on a template page called 'single-videos.php' A custom field called 'Video URL', 'Video Width' and ...
3
votes
1answer
48 views

Displaying custom posts only if custom meta box's date is not expired

I have a problem with displaying custom posts - I want each post to show only if a date set in a custom field has not passed. I can't figure out the where I should put the if statement in the code. ...
0
votes
0answers
27 views

Grabbing data from Meta Box

I am using someone elses code for uploading files to a custom post type, and I need to be able to get the URL back from it. In the editor, the value is the URL so that isn't an issue, but I need to ...
1
vote
2answers
96 views

Trigger JS in custom meta box if a featured image is loaded/exists

Playing with WordPress customization I created a meta box with several others that report back details of the post. One meta box evaluates the featured image but I am having trouble figuring out how ...
4
votes
1answer
79 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 ...
3
votes
2answers
131 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\...
1
vote
1answer
36 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
48 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
1answer
25 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); var_dump($...
0
votes
0answers
50 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
35 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
83 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
27 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 = get_post_meta(get_the_ID(),'...
3
votes
1answer
81 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( '...
1
vote
1answer
84 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
72 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( 'designation_save_meta_box_data',...
0
votes
1answer
199 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
34 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] => ...
1
vote
0answers
50 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
40 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
81 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
52 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); if($query->...
0
votes
1answer
28 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
349 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 ...
-1
votes
1answer
41 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. http://www....
0
votes
3answers
158 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
122 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( 'my-...
1
vote
1answer
220 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
588 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
0answers
91 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 wpostmeta1....
1
vote
1answer
226 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
260 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' => array('...
0
votes
1answer
115 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
81 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 ...
0
votes
1answer
177 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 '</...
-1
votes
1answer
108 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
46 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
203 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
153 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 Meta_Box_Media_Upload();...
0
votes
2answers
308 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

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