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
2k views

How to print meta description to posts? [closed]

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
514 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
2k 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
4k 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
1k 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
312 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
2answers
61 views

Custom post meta field effect on the performance on the post

I have the posts which have many custom defined meta fields. On posts I am calling them on requirement using get_post_meta. Means for 10 meta fields I am using it 10 times. Am I doing it right? ...
2
votes
1answer
97 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
547 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 ...
2
votes
1answer
220 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
259 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
5answers
2k 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

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
1answer
2k 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
2k 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
85 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
825 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
36 views

Getting value from get_post_custom

I have added a custom meta box to a category that shows up fine. The only purpose of this metabox is to supply a link to the post. I can see that the box works because my test link is saved in the ...
1
vote
0answers
60 views

How to use pagination with get_post_meta

I have a Products Page that i am using to add products using custom metaboxes this is the code for my page <div class="container products"> <div class="row"> <?php ...
1
vote
1answer
288 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
275 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
85 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
2answers
138 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
986 views

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

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
129 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
369 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
5k 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
928 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
1answer
2k 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
29 views

How to echo value of a meta select box to the browser

I think I'm echoing the value of the selected option from my select meta box wrongly. Nothing is being shown in the browser. Functions.php : function add_custom_meta_box() { add_meta_box( ...
0
votes
1answer
460 views

Meta Data for Custom Post Type not saving

I'm in the process of building a custom plugin, and I'm having trouble saving meta data for the custom post type. The boxes display correctly in the editor, but when I click Publish or Save Draft, the ...
0
votes
2answers
70 views

Setting Post Title via Meta Data returns Auto-draft

I've read here and other places about setting a post's title based on it's metadata. Unfortunately I'm unable to get it working and I'm hoping someone else can point me in the proper direction or ...
0
votes
2answers
288 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
293 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
108 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
403 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
319 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
134 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
79 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
2answers
74 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
2k 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
950 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
1answer
23 views

How can i get multi checkboxes value in metbox?

I make list of check boxes by WordPress meta-box and i can not get this value in my theme. i can get my text value with this code <? echo get_post_meta($post->ID, $prefix . 'text', true); ...
0
votes
1answer
17 views

Related query shows same image in loop

I'm using the code below to query all other posts with same value in custom field FeaturedArtists. Works great except the images. All images are the same as the current post. If I change ...
0
votes
1answer
146 views

Display custom field meta outside loop, site wide

I've created a custom field ("breaking") with the goal that whenever one post has this field present, it will display the value in the header throughout the site (that is, all posts, pages, archives, ...
0
votes
1answer
62 views

Trying to write shortcode with get_post_meta but isn't working

I am trying to write a plugin with a CPT and have a shortcode to display the data. I can get 'the_title()' to work and display the title of the post type but using 'get_post_meta()' I can't seem to ...
0
votes
1answer
262 views

adding meta tag without plugin

Is it possible to add meta title, meta description, meta keywords in every page without installing plugin? My client require not to install plugin. I am curious about this case, all I know is the ...
0
votes
1answer
32 views

Can't Output get_post_meta?

I have a custom field for my post and I am trying to output it onto my post's page but nothing appears. I know my code works otherwise if instead of trying to call my custom field, I use a fixed ...
0
votes
1answer
119 views

get_post_meta is returning image id

I'm using this script to get image filename, stored in a custom meta called background: $background = get_post_meta( '22', 'background', true ); echo $background; But it is returning the id of the ...