Tagged Questions

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
71 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 ...
1
vote
1answer
82 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 ...
0
votes
0answers
610 views

How to add fields to _wp_attachment_metadata?

I'm developing a custom metabox with the possibility to upload images and give the user the possibility of deciding whether those images are to be displayed on the front end or not, instead of having ...
0
votes
0answers
32 views

Get_post_meta returns Array instead of actual value [duplicate]

With the PODS plugin in Wordpress, I've created a custom post type called project. Within project I've created a few custom fields. One of those is project_thumb. The thing is; When I want to display ...
-1
votes
1answer
64 views

delete blank space in post_meta empty [closed]

Like title said. I need delete blank space when post_meta don't have value. Code example: <?php global $wp_query; $postid = $wp_query->post->ID; $meta = get_post_meta($postid, 'direccion', ...
0
votes
1answer
53 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
29 views

delete value 0 in post meta [closed]

I have a simple question. I have this code and its correct, <?php global $wp_query; $postid = $wp_query->post->ID; $meta = get_post_meta($postid, 'codigopostal', true); if($meta != $empty) { ...
0
votes
1answer
115 views

Get post_meta of children and compare to current page ID

I am stumped on a bit of php code in my template. I have a custom field named "services" with a value such as "2402, 2366, 78" These are page ID's. In my template I want to do the following: Get any ...
0
votes
1answer
153 views

If metabox has content display content

I know how to display field content if the field has content. $monday = get_post_meta($post->ID, '_cmb_open_monday', true); if ( ! empty ( $monday ) ) { echo 'content'; } How do I display ...
0
votes
2answers
277 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
33 views

Display articles related to a custom field on a page

I have a little problem to display some articles related to a parent page. I explain. On the first hand I have a page with a model template. On the wordpress editor part, I create a custom meta field ...
0
votes
1answer
257 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> ...
2
votes
1answer
505 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 ...
0
votes
1answer
104 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
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
0answers
98 views

Custom Field: Display only if a specific key is selected outside the loop

I might be doing this all wrong. I have a custom field called "enable_adsense" and the value can be either "yes" or "no" What I'm trying to do is display something if the value is "yes" and something ...
0
votes
1answer
31 views

Return only custom post types for the page, not all

I'm currently working my way through some custom posts (for the first time). I'm managing to return the bits I need using this <div class="pagered"> <h1 ...
0
votes
2answers
35 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 ...
-1
votes
1answer
172 views

get posts based on category and post meta

I am coding a Live Show box for a radio website to show who is on air and who is up next. I've been using the get_post function to retrieve posts based on the category (in this case the day of the ...
1
vote
2answers
131 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 = ...
0
votes
1answer
128 views

get_post_meta is always empty when I use wp_mail

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 = ...
0
votes
2answers
762 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
0answers
254 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 ...
0
votes
1answer
107 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 ...
1
vote
1answer
923 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
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 ...
0
votes
1answer
213 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
238 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
2answers
271 views

Multiple If else statements on Search Result Page

Ok, I have a few CPT's setup with a metabox that only requires some values for some categories. When searching a specific category, I want to display a link to the value (which is a url) if it exists ...
0
votes
1answer
170 views

Related posts and custom meta_box?

I am trying to code the ability to pick which posts should be included as related to the current post the user is editing. I have used @MikeSchinkel very helpfull post here, to include a list of ...
0
votes
0answers
569 views

Update Post Meta for Arrays — Remove/Replace Single Value from Multi Dimensional Array

I am trying to unset/remove then replace/update a single value from a post meta field, but my code for array_push() and unset() are removing all of the values from each array. Here are the two halves ...
0
votes
1answer
466 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
62 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
396 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
1answer
117 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 ...
0
votes
2answers
309 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 ...
4
votes
1answer
507 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 = ...
0
votes
1answer
219 views

get_post_meta image width for lazy load

I'm trying to lazy load a page of images in Wordpress - I've tried the plugins but none of them seem to work(I only want to lazy load image on some pages.) So I'm now trying to do it with a plugin - ...
0
votes
0answers
22 views

How do I retrieve a value from a multi - dimensional array using get_post_meta? [duplicate]

I know that I need to use get_post_meta(31, $custom_repeatable, true); The post_id is 31 and the meta_value is $custom_repeatable. I would like to display the value hamsters repeat one only . My ...
-1
votes
1answer
153 views

How do I just display the part of the array that I want to? [closed]

I would like to take a stored array, from the meta_value $custom_repeatable and just display the line 'hamsters repeat one', but the following code doesn't display it how I'd like. Here is the code: ...
-2
votes
1answer
797 views

echo is just displaying the word 'array', rather than the array [closed]

I'm trying to see the structure of an array, but when I try to echo the array, all it says is 'array'. Please can someone explain how I can see the structure of an array? add_shortcode('book', ...
1
vote
2answers
1k 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 ...
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 ...
0
votes
0answers
57 views

getting a post id from a custom type post

changed a wordpress to use custom type posts instead of pages. I'm Trying to update a plugin to work with this change. currently I'm stuck with just getting the right id from the post here's the ...
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 ...
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 ...
0
votes
1answer
80 views

How we can get “get_post_meta” of specific user who added it

Basically i have front end form which store the notes and tags of post. And every user who logged in can store there own notes and tags. But i want when he view the notes and tags he can only see here ...
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
2answers
131 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 ...
2
votes
1answer
218 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 ...