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

5
votes
2answers
1k views

How to print meta description to posts?

I want to show my meta description content above posts. But i don't know what function I need to call. Resume: i want to put meta description from Yoast Seo above the posts body.
4
votes
1answer
448 views

What is the index [0] for on post meta fields?

Trying to improve my PHP knowledge through test and try! I am confused on [0] arguments at following WordPress PHP code global $post; $custom = get_post_custom($post->ID); $price = ...
4
votes
2answers
1k views

How we get_post_meta without post id

I want to get my all posts-meta, But on the base of key. For example the main query for getting the post-meta is <?php $meta_values = get_post_meta($post_id, $key, $single); ?> Now i want ...
4
votes
2answers
2k views

Display Yoast WordPress SEO title in archive template

The WordPress SEO plugin by Yoast allows users to add SEO titles and meta descriptions to taxonomy term archive pages. These are then used in the head of the document. I´m trying to display the SEO ...
3
votes
1answer
636 views

Formatting custom meta box date from YYYY/MM/DD to a more readable alternative

QUESTION This is following a previous question that was graciously answered by Milo earlier here - How to sort CPT by custom meta value (date), and return posts month by month In short, I'm having ...
3
votes
1answer
234 views

Using get_post_meta with new_to_publish

I'm trying to read the custom fields set by the user when publishing a new post: function doSomething($post) { $meta = get_post_meta($post->ID); error_log("post meta: ".print_r($meta, ...
2
votes
1answer
91 views

Add Post Url to Manage Edit Screen

I'm trying to add a column to the manage screen that displays the Title and url of the post. I got the Title to work but it's not pulling the url. Basically I just want to show the url that's not ...
2
votes
1answer
172 views

How can I display my custom metaboxes on a custom post template?

I'm fairly new to PHP/wordpress, and this is actually the first time I haven't been able to answer a question through google! I'm working on getting up to speed with PHP/WP generally, but I can't seem ...
1
vote
2answers
199 views

Ordering posts by metadata

In my plugin, I use these instructions to obtain a list of posts: $args = array( 'numberposts' => -1, 'offset' => 0, 'meta_query' => array( array( ...
1
vote
1answer
953 views

Need help on creating If-statement for custom meta fields

I'm using Wordpress. I have a movie review website called Filmblurb. For my blog posts, I'm trying to create posts with different categories. Under the "Reviews" category, I have a "Details" box that ...
1
vote
5answers
714 views

Get meta_id along with meta_key and meta_value

Is it somehow possible to get_post_meta or get_post_custom and have meta_id returned along with the meta_value? For example: $data = get_post_meta( $post_id, 'my_key' ); // returns this: array( 0 ...
1
vote
1answer
1k views

How can I get_post_meta() in the most efficient way?

I have a custom post type for a real estate site, and the theme displays 9 properties in a grid on the home page. I don't think its written terribly efficiently - I'm getting about 160 queries on the ...
1
vote
2answers
653 views

display specific custom fields

I have few custom field assigned for each post, like: "Club" with value "club1" "Date" with value "date1" and so on... Now, I want to display from all the custom fields just those 2 " club" and ...
1
vote
1answer
79 views

dynamically generating plugin syntax

I have downloaded an audio player plugin for WP. the syntax is very simple. You just add the line [audio:my_file.mp3] to your post editor/excerpt, and call it in the loop with the_content() or ...
1
vote
1answer
668 views

Widget: Custom Post Type Post Listing Dropdown on Admin Side

Widget: I'm making a custom widget with the following functionality on the admin side. 3 text fields 2 dropdown menus to select posts by title (both from a single custom post type) Right now, ...
1
vote
1answer
19 views

How to count post meta key values for all posts in database

In my post meta data I have the following 'key' for every post: "image_details" a typical value of which is an array such as: ...
1
vote
1answer
55 views

get_post_meta doesn't work

I created a custom meta box inside a page but I can't display the content! I'm inside the loop and here there is the code of my functions.php: $meta_box['portfolio'] = array( 'id' => ...
1
vote
1answer
56 views

Custom Meta box only returns most recent value on page

I created a custom post type and a custom meta box where I create a new post and input a Youtube URL into the meta box, and I call for it on a custom template page inside an iframe that is inside in ...
1
vote
0answers
198 views

How to hook a filter to catch get_post_meta when alternate a custom field output?

How to hook a filter to catch get_post_meta when alternate a custom field output? I have fill a custom field(meta data) in a post, just like this: <!--:de-->Nominale ...
1
vote
2answers
87 views

Why is my get_post_meta always empty

I made this action hook which will send an email to the users every time a new post in the custom post type "events" is made. function email_members($post_id) { global $wpdb; $usersarray = ...
1
vote
1answer
334 views

How to display Yoast SEO meta description in archive template for each post instead of the_excerpt()?

I read this question but it wasn't what I was looking for exactly. I'm new to Wordpress and a little confuse with the functions and everything. How can I get the metadescription in the loop for each ...
1
vote
0answers
104 views

Change Post Template based on post meta?

I am trying to figure out a way to use a custom template within my plugin. I would like to avoid using a custom post type if possible. I searched for a way to add my theme file to the dropdown list ...
1
vote
1answer
323 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
2answers
3k views

How to get meta box data to display on a page

I am trying to piece together a Metabox with 3 text editor fields for a custom post type. The box is showing up and appears to be saving on the custom post type entries but I can't get the data to ...
0
votes
1answer
1k views

Display post details by post ID

I need to display post details by ID on front page template (front-page.php). On the front page I want to display the post’s title, excerpt & featured image. I have tried to do that but no idea ...
0
votes
2answers
119 views

Trying to get property of non-object error using get_post_meta()

I made a simple function for post_meta, in functions.php: // Top Sub Heading (top_sub) FROM CUSTOM FIELD function topSub( $Trunckvalue = null ) { global $post; $TopSub = get_post_meta( ...
0
votes
1answer
89 views

Trying to get file name

I have a custom meta box to store pdf files. For this input, I'm using type="media" to acess wordpress media library. Now I can't get the file name. Here is my entire loop: <ul> ...
0
votes
1answer
67 views

Remove last character in get_post_meta

I have a custom field that contains a sentence along with a punctuation mark at the end. I am looking to use this field as a title of the article on my homepage, but in doing so I would like to remove ...
0
votes
1answer
327 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
2answers
162 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
2answers
104 views

wp_query not resetting, last post hanging

im creating a wordpress query for custom taxonomy. However im unable to get the last post that i queried to go to the permalink. Please could somebody help me get this query right, much appreciated in ...
0
votes
1answer
65 views

How to display childrens custom fields?

I need help, I have a page that I want to display content from the page children, I get the content but not the custom fields! I've tried this but it dosnt work, what am I doing wrong? <?php ...
0
votes
1answer
695 views

get_permalink vs the_permalink

I am filtering the_permalink to return a custom structure function append_query_string($url) { $url_endpoint = get_permalink(); $url_endpoint = parse_url( $url_endpoint ); $url_endpoint = ...
0
votes
2answers
73 views

how to display custom fields of post on a web page

I want to ask that how can i dispaly custom field of a post on a web page . I have used get_post_meta but it resulted in just an array .i cant figure out what is the problem
0
votes
1answer
1k views

get_post_meta - get a single value

When I do get_post_meta($post->ID, "company_wp_box_g", false) I am getting back an array of key/values pairs. array (size=1) 0 => array (size=7) 'f_name' => string ...
0
votes
1answer
2k views

Display Custom Meta Box Field Only If Value is Present

I'm messing around with Custom Meta Boxes in WP for the first time and was wondering how I go about displaying the fields that only have values attached to it. For example I've got a meta box with an ...
0
votes
1answer
715 views

How do i get the attached images with custom value checked?

I have added a custom field to the image attachement. When this custom field is checked the image will be part of a carousel on the home page. Now i am able to get the custom field to work and save ...
0
votes
2answers
50 views

Displaying values from related field - if empty shows current post type's link and title

I'm working with custom post types. In the post type awards I have a relationship field that links each award to a post from the post type project. I'm using the following code to return the values ...
0
votes
1answer
38 views

Difficultly changing date format in post meta value

I have a custom post type with a custom field that takes a date. The posts are later ordered by the date in that custom field. Unfortuately I formatted the date incorrectly and there are already a ...
0
votes
1answer
42 views

How can I get some of a posts meta data whilst it is still inserting?

I'm trying to make a function where a child post of a certain post type inherits the same title and slug as its parent. I'm using WP Types to define my post types and their relationships. But I'm ...
0
votes
1answer
29 views

get_post_meta inside echo [closed]

I have a serious problem :) I have this code: <?php global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, 'provinciadestacada', true); ?> And i want include ...
0
votes
1answer
43 views

Display Post Meta in Header

I'm trying to get page post meta in my header so I can set some meta tags. I tried to get the global post variable but it only return true. <?php global $post; global $wp_query; echo ...
0
votes
2answers
25 views

put saved metabox values back into fields and then display on the front end

i have a group of metaboxes which i finally are now saving but am struggling to get the saved values back into the input boxes they came from. so for example i have a meta field called link text and ...
0
votes
2answers
196 views

Where is the key _wp_page_template passed?

When adding custom post meta boxes, I understand that whatever name attribute input you put would be passed through the form into the server. Hence, if I have <input type="text" ...
0
votes
1answer
76 views

how to fire join query with post_meta

I have print sql query that runs within 'posts_where' filter and its like: SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'shop_order' AND post_date >= '2013-08-26' AND ...
0
votes
1answer
150 views

Image not showing using a custom function and get_post_meta

I'm trying to create a function to display either a theme option or custom images based on user input. So basically, it's a custom meta box. The user selects either a display header image OR they can ...
0
votes
1answer
136 views

How do I save each option in a multiple select menu as it's own meta_key + meta_value pair?

How do I save each option in a multiple select menu as it's own meta_key + meta_value pair? This is the basic multiple select menu. Note: multiple select menus allow you to select more than one ...
0
votes
1answer
318 views

Post meta select input, if statement

I have created a meta box with a select input (drop down menu). It has a few values and I want to display different content depends on which value the user selects. I am just unsure how to display ...
0
votes
1answer
53 views

get_post_meta in one post only

I have a rough demo here to try and illustrate my problem. http://www.ttmt.org.uk I have six pages with titles - Page One, Two etc. On a index/home page I'm creating a btn/div to link to each ...
0
votes
1answer
90 views

Random element in get_post_meta array

I have a custom field that contains a list of comma separated colors. I want to randomly select one of those colors. If get_post_meta returns an array I thought I could randomly pick from that ...