Questions tagged [get-post-meta]

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

67 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3
votes
0answers
756 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 $...
2
votes
0answers
226 views

get_post_meta returning empty string when data shows in the database

I'm absolutely stumped and I'm hoping this is something stupid that I just can't see because I'm too close to it. Working on an LMS using Sensei. Trying to get the course_id from a lesson. Pretty ...
1
vote
0answers
22 views

Get User Post if Private

I'd like to display a message when current user's post is set to private. The code below does this, however only works when you are on the actual post page. I'd like for my message to be displayed ...
1
vote
1answer
91 views

Hide custom meta data if empty

I have a custom field created for WooCommerce products. I am using the below code to create // ADD CUSTOM WOO DATA add_action('woocommerce_product_options_general_product_data', '...
1
vote
1answer
24 views

Where to put meta Keys

Hello im creating my custom checkbox in gallery and i already add that , but save doesn't work , can someone take a look and tell me where should i put meta keys ? function wporg_add_custom_box() { $...
1
vote
0answers
25 views

delete all post with certain meta_keys

I'm currently trying to delete metakeys once my plugin is uninstalled to keep the database clean. My code is as follows: Array of meta_keys that are created $keys = array ( '_menu_item_icon', ...
1
vote
1answer
55 views

Can't access post meta on new post creation (cpt)

I'm using... function on_CPT_request_publish( $new, $old, $post ) { // ----------------- Start of Function ----------------- if ( ( $new == 'publish' ) && ( $old != 'publish' ) && (...
1
vote
0answers
283 views

Run Shortcode of post's custom field in functions.php / Plugin

After 3 or 4 hours of searching the web for a solution, I abandoned it and hopefully you can help me? I added a sub-headline as a custom field (subheadlineclass). That works pretty. I can save, edit ...
1
vote
0answers
37 views

get_post_metadata causing some meta data to fail

I'm using the following code to extend subscription trial lengths, which requires me to modify the metadata. the problem of, other metadata is also failing, such as custom attributes and variations. ...
1
vote
1answer
140 views

Single-post preview repeats thumbnails in Jupiter Recent Posts widget

I'm using the Jupiter theme version 5.1.8 with WordPress version 4.6. When I preview a single post, the thumbnails displayed by the Jupiter theme's Recent Posts widget are all repeats of the current ...
1
vote
0answers
89 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 ...
1
vote
2answers
762 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
vote
1answer
161 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
1answer
280 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 ...
0
votes
1answer
28 views

Update Post meta with custom variable

I Just want to update (edit existing) the custom meta box variable from front-end. I got a form Front end post editing using a form & process things but in this code post-title i can edit & ...
0
votes
1answer
18 views

How To Tell If a Custom Field Was Made with ACF, Metabox.io, Carbon Fields, Custom Built, etc?

I am working on a plugin that will be using custom fields, but was curious if there was a way to tell which plugin/library created those custom fields. The reason I am trying to find this distinction ...
0
votes
1answer
62 views

Allow HTML in Custom Metabox area

I know there are many questions related to my question, but sincerely i was unable to get solution. My question is simple, how can i allow html in textarea in custom metabox on post. So far i have ...
0
votes
0answers
82 views

get custom post meta inside custom taxonomy

Hello I create a taxonomy for one of my custom type and add meta field on the backend , I would like to display it in the front end , my code is currently: Could you help me ? /* Add Image Upload to ...
0
votes
0answers
39 views

Get meta values from parent post and save in child post

I have a custom post type "E-Books" with two categories "E-Book Title" and "Chapter Page", and custom meta boxes (table of contents, etc). The E-Book post type uses one page template, and displays ...
0
votes
0answers
21 views

Generate post content from meta fields

I have a custom post type (match). Each posts on this CPT has one ore more custom fields. Is it possible to automatic generate the 'post content' with the value of my custom fields on these posts? ...
0
votes
0answers
12 views

Is it possible to remove a conditional value from WordPress custom metabox

Here I have attached the screenshot from MySQL for easy understanding. In this meta value a: denotes total no of users liked the post. User denotes user with id user-id My question : Is it possible ...
0
votes
1answer
48 views

Reverse Cross-Sells (WooCommerce)

When you run get_post_meta( get_the_ID(), '_crosssell_ids',true); you get an array of all the products that the current product cross sells to. How do I reverse that? To get all the products that ...
0
votes
1answer
58 views

get_post_meta not working with variable as a post_id for dynamically get the postid

I would like to use the get_post_meta to pull a value from a CPT dynamically and then send a email. The problem is that the get_post_meta($post->ID, ... part of the code does not pull the email ...
0
votes
1answer
205 views

update_post_meta in loop changing ALL values

I have a button on the frontend that updates the value of post meta on the backend, and it's nested inside a loop. However, on submit it updates the value on ALL posts. What am I doing wrong? ...
0
votes
1answer
376 views

Get value from an input field and pass into update_meta_data as $meta_value

I am building a woocommerce site and I have some input fields the on the product page. one is for recipient email (its for a gift car). Everything works, and the recipient email is saved on the order, ...
0
votes
0answers
316 views

Save, update, get and sanitize post meta as HTML not plain

My post meta always is plain text HTML striped from it I need to Save, update, get and sanitize post meta as HTML not plain here is all my related code to this post meta filed Retrieve from ...
0
votes
0answers
24 views

How to get post that has non zero or greater than zero meta value

How to get post that has non zero or greater than zero meta value $args = array( 'sort_order' => 'asc', 'sort_column' => 'post_title', 'hierarchical' => 1, 'exclude' => '', 'include' =>...
0
votes
2answers
81 views

Data not displaying in text field

I have been working on trying to get data to store and display on a CPT field. The code I have is here: function fhaac_subject_box_callback( $post ){ wp_nonce_field( basename(__FILE__ ), '...
0
votes
0answers
126 views

How to get a post meta value and pass that to update_option when a post is created or updated?

When a user publishes or updates a post I want to get a post meta value from that post itself. Then I want to use update_option() to pass that value into the get_option() name. I've been trying ...
0
votes
1answer
91 views

do_shortcode based on _thumbnail_id

Situation I've created a Custom Post Type called 'Banners'. On each post I'm able to add a featured image. This will be saved in my database and will get an _thumbnail_id. Also on each post edit page, ...
0
votes
1answer
2k views

Make Custom Fields Public in JSON - API

How do i make the custom fields public in rest API? I have added a custom field to the rest api. the challenge is - The metadata is returned when i am signed in my browser. if i try as public using ...
0
votes
1answer
351 views

Create Meta boxes dynamically

I followed and created a meta box using all code from this question here: Create more Meta Boxes as needed Basically only two fields are created when you click on Add track button: Song title field ...
0
votes
0answers
173 views

Return ACF Field value function

I am working on a function that I would like to access from anywhere within my theme when I call it. I am using the ACF flexible content field and I am retrieving a text field value. The value of my ...
0
votes
1answer
138 views

Collect custom post in a calendar

I'm working on a site in which I have incorporated a calendar of events, which also serves as navigation in the events page. That is to say that when I click on a calendar date associated events occur....
0
votes
1answer
587 views

get_post_meta not work in php foreach

i have these codes : foreach ( $ids as $idss ) { echo get_post_meta($idss, 'IMDB', true); } i have search box with Form element that search and find all id ( $ids ) of searched word . i want to ...
0
votes
1answer
734 views

How to get post meta for custom post type and taxonomy

I am trying to access post meta for custom post type and taxonomy using WP_Query and then query the posts with that specific post meta. So far I have tied the following code: $hot_args = array( ...
0
votes
1answer
179 views

Get posts with Taxonomy term meta

I want to display posts by categories. In my categories, I just want to display the posts that have the term meta between 100 and 200. How can I do that properly?
0
votes
1answer
37 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
2answers
79 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(),'...
0
votes
1answer
99 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
1answer
29 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-...
0
votes
0answers
222 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....
0
votes
0answers
342 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
512 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" ...
0
votes
1answer
426 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
1answer
1k views

Define category ID using get_post_meta

I need to define the Category ID in my singles page through custom fields so that i can load a different category depending on the page. This is what i have so far and its not working. Any help would ...
0
votes
0answers
105 views

Performace on 1 million plus meta fields vs 1 field with 1 million multi array

We are potentially looking into building a counter in a post_type. So a post meta field wil be created with some data like total downloads and downloads left (tied to user ID). We expect up to one ...
0
votes
1answer
396 views

Editor meta box Showing but not saving

I am trying to create an editor meta box and I have been following tips found in other similar questions without luck in getting the meta box to save and display its content. The meta box shows but ...
0
votes
0answers
838 views

Automatically add custom fields (post_meta) to all published posts, hourly, via wp_cron?

I'm trying to update the post meta of all published posts hourly (via wp_cron) with the code below: if ( ! wp_next_scheduled( 'postviews_updatedcounts_hourly_event' ) ) { wp_schedule_event( time()...
0
votes
1answer
81 views

Howto: use existing post_meta as options for a different metabox (checkboxes or list)

I want to create an "Employee" Custom Post Type ("Add New Employee") wherein the employee may belong to one or many offices. The user needs to be able to add/edit/delete offices via a separate "...