Post meta is a data set containing additional core as well as custom post information.

learn more… | top users | synonyms

0
votes
0answers
46 views

WP_cron not updating post meta, instead clearing it

I'm trying to store social media follower count (ex. FB fans, Twitter followers) in post meta daily with wp_cron. If I manually save the post it will save the social media count numbers correctly in ...
0
votes
1answer
28 views

Retrieve posts from meta key

I'm trying to query the list of posts using the meta_key but the result I got back was an empty array. To write the data, I used the following codes: $post_id = 2; $user_key = ...
0
votes
0answers
21 views

Problem saving meta data

I'm making my first WordPress plugin. I used an example to save text that an administrator enters when submitting a new post, but the meta data is not saving. Can anyone help on that? /** * Adds a ...
0
votes
1answer
47 views

Show number of posts by logged in user

How to display the number of posts written by the logged in user. Here is what i got from the codex so far <?php echo 'Number of posts published by user: ' . count_user_posts( 5 ); ?>
0
votes
1answer
49 views

Get audio metadata on file upload

I am trying to fetch all audio metadata when I upload a file. This all happens in a plugin, and I currently use the add_attachment action to trigger my custom function : // link add_action( ...
0
votes
2answers
76 views

Only allow one meta key value per post in a category

I have created a meta box for a theme I am working on, it is a simple meta box with a check box for featured post. The problem is user can tick that check box for multiple posts in the same category. ...
0
votes
1answer
72 views

Hide posts with meta key in WP_Query

I was reading this post to "Exclude posts with specific meta_value" but it does not work correctly. Here is the arguments I am passing to WP_Query : $args=array( 'cat' => $catid, ...
0
votes
0answers
63 views

Create a Gallery and update Post Parent of Attachment Images

I need to create a gallery for a custom-post and update the post_patent of every image with the new gallery ID function create_tfuse_gallery_group($post_id) { if ( get_post_type( $post_id ) == ...
4
votes
2answers
311 views

When using add_post_meta and update_post_meta, is there any way to give the individual arrays keys?

When adding arrays to post meta, using add_post_meta, new sub-arrays are added. I was wondering if there was a way to have those sub-arrays named. so instead of ending up with array([0](2,3), ...
3
votes
1answer
131 views

Multiple meta values for same meta_key adding on “Preview Changes” hit but not on saving or updating post

I'm taking multiple location values with each post, so it's an array (always). My post meta form field is like so: <select name="<?php echo $project_prefix; ?>offer_locations[]" id="<?php ...
0
votes
2answers
62 views

Modify WP_Post before processing

I am looking for a way to modify WP_Post object before it's processed and displayed on the page. Reason - I built my site when WP was still in version 2.0, or even earlier. I didn't attend to it for ...
0
votes
0answers
29 views

Query all posts sorting first by the ones that match criteria, then the rest

I have two custom post-types 'office' and 'work'. A work is made by one office (I store the office ID in a meta of the work, named OFFICE); Now, in single-office.php, I need to list all the works, ...
0
votes
1answer
27 views

How does WP decide how to display a page

I am new to WP. I tried reading up as much as I possibly can online, and via browsing through the files. As far as I can tell, no physical pages/links are stored on the disk, so when a page is ...
0
votes
1answer
41 views

Hide post title input for all roles except admin

How would this function need to be updated to exclude the admin? add_action('admin_init', 'wpse_110427_hide_title'); function wpse_110427_hide_title() { if (current_user_can('subscriber')) ...
0
votes
0answers
45 views

Search on Category and BETWEEN custom meta field

Background I am building simple car theme where I want to review cars, however, I'm really struggling with my search implementation. I have added a couple of custom meta fields to the post including ...
2
votes
3answers
130 views

Order posts according to user defined order for meta values?

I have set up some CPTs and storing a meta key/val for each of them. When I get those posts, I need to order them by the meta value, but, the order of the meta values will be defined in an array by ...
0
votes
0answers
19 views

Ordering results by last login date

I want to order posts by a post meta field and last login date. Here I use a custom post type called 'Agents'. Agents is a user group and they can login through frontend. For Agent logins, I record ...
0
votes
0answers
32 views

How to link images to a certain property type

I've build a web page, in which an user certain data; the user can add also images, and once everything is done, he/she clicks submit and a Property post type is added. The problem is that the images ...
1
vote
1answer
27 views

Query metas (and not : query posts by metas)

If I understood well, the WP_Meta_Query from Wordpress allows you to query posts by metas. But what I would like to do is to fetch metas; not posts. And I would like to fetch those metas without any ...
0
votes
0answers
123 views

Add post meta to search in admin of a custom post type

I am using woocommerce in a wordpress theme and I can't get the search functionality in the admin to include a meta value of 'shop_order' custom posts type. I've been trying to modify the following ...
0
votes
1answer
353 views

How to enable revisions for post meta data?

Normally wordpress keeps revision of wp_post table. But for generating a report I need some custom fields to be tracked while any update happens. As custom fields are saved in wp_postmeta table I need ...
0
votes
0answers
81 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 ...
0
votes
1answer
33 views

How to add more than one custom metadata as filter on the post list page?

To add a filter based on metadata to a post we use the following format: $wp_query->query_vars['meta_key'] = 'meta_key_name'; $wp_query->query_vars['meta_value'] = meta_value; How can I add ...
0
votes
1answer
79 views

How to display Meta Field Value?

I am trying to display the value of a Meta field on single.php. The Meta Key is 'current_rank'. I tried... <?php echo get_post_meta( get_the_ID(), 'current_rank', true); ?> This code does ...
0
votes
1answer
31 views

Update event post meta each day automaticaly

Is there any way to update post meta value each day (daily automaticaly) ? For example my event has started each day at 10pm my current post meta is: 2015-01-01 10:00 next day i should change it to ...
0
votes
1answer
96 views

Check if value exists before saving

I added an extra registration field: function wooc_extra_register_fields() { ?><p class="form-row form-row-first"> <label for="billing_cpf"><?php _e( 'CPF', ...
1
vote
1answer
147 views

How to sanitize post meta field value?

I have added a meta field for text input. I want to allow some html tags such as <strong> and <i> For example: <strong>hello</strong> world I can save the input field value ...
0
votes
0answers
69 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
2answers
122 views

Echo out custom fields in comments

I am trying to figure out how to echo 4 created fields from a plugin in my theme template for the comment form and customize the comments output as well. The plugin I am using lets me add custom ...
0
votes
1answer
786 views

What is the code to get the download link for a product in WooCommerce?

I'm trying to add the direct download link of a product to a button, but I'm stuck. What I tried is this <a href="<?php echo $product->downloadable_files; ?>">Download</a> ...
0
votes
0answers
32 views

Get Meta Values and Count based on Meta Keys

Is there a function or a script to get the distinct meta values given a meta key and post type? I was hoping for a function similar to get_terms() for taxonomy. In addition to each meta value, there ...
0
votes
1answer
127 views

Get meta value when the page is a blog archive

I'm using custom metaboxes on my pages. For example: header icon. I created a page for the news on my site. I selected it as a blog archive page under Settings->Reading page. Unfortunately I can't ...
0
votes
0answers
14 views

how to show the post-meta for particular custom field in my post? [duplicate]

function add_custom_field() { add_meta_box( 'my_field', 'My Field', 'add_input', 'post' ); } add_action( 'add_meta_boxes', 'add_custom_field' ); function add_input( $post ) { $value = ...
0
votes
0answers
58 views

How to update post meta in schedule event action-function?

I want to execute something like this. What I must to change in following code? wp_schedule_event( time(), 'hourly', $string); add_action($string, 'do_this_hourly'); function do_this_hourly() { ...
1
vote
1answer
76 views

Creating terms vs custom post meta to save data?

I am making a news aggregation site on wordpress. I've to save domains of source urls somewhere. Sometimes source url could be same for multiple posts. So I'm confused how should I save the data. ...
0
votes
1answer
17 views

What is the best way to query posts based on live data?

I work on developing plugin for WordPress. In each post, there are rating bar that users can rate 1-5 star to post. I calculate the grow rate based on (Stars in past 7 day from now). I want to show ...
0
votes
0answers
159 views

Problem serializing single quote and double quote into post meta

This is a silly question and I shouldn't have to be spending this much time on this issue. I've been trying all sorts of things without any success. I am trying to serialize a string with single ...
1
vote
2answers
52 views

How to get the total number of meta_values based on a custom post type?

I need to display the total number of votes that have been made for a specific custom post type. Here's an example of how the wp_postmeta table looks for these keys/values: meta_id post_id meta_key ...
5
votes
1answer
178 views

So much data in postmeta

Last year started using custom fields and in one year I have 230,540 rows in wp_postmeta table. This year will add more data and new fields and I don't know what to do, to create new table or continue ...
-1
votes
1answer
97 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
0answers
65 views

Adding description to wordpress blog post through wp-admin panel

Is there a way to add a description to my Wordpress blog post through wp-admin panel?
0
votes
1answer
53 views

Search one custom field?

In posts there is in custom field named "color". I have custom search page template, and I would like to show search results only from that one custom field. How to limit search to look just in one ...
0
votes
0answers
35 views

Remove metabox container and header

Is it possible to remove the whole header of my metabox (title+toggle icon) and the container (.postbox) ? I wonder I can use css to remove them, but is it the best solution?
0
votes
1answer
41 views

Use WP_Query in shortcode

I'm trying to get meta information from the first four posts that have a meta key equal to Sedan, then format that posts meta in order to set up gallery type display boxes. I believe it has something ...
0
votes
0answers
71 views

Can't save meta field value if the title not set

I'm using the example from WordPress Codex (https://codex.wordpress.org/Function_Reference/add_meta_box#Procedural) to add and save meta box values. Unfortunately I can't save the value of the meta ...
0
votes
0answers
141 views

Pre_get_posts meta query value serialized array using multiple URL parameters

Using the 'pre_get_posts' action I'm looking to return all posts which match multiple URL parameters by defining the meta_query. For example: example.com/?size=large,small&options=green,blue,red ...
0
votes
0answers
59 views

How To Add Custom Meta Field Select/Radio Box to Post List Bulk Edit Mode

How can you add a radio fieldset to a custom post-types post list bulk edit screen for a custom meta field? Please provide in depth code example and explanation and thanks in advance. The ...
0
votes
1answer
324 views

Structure of postmeta meta_value for woocommerce product download

So I'm working on a monster script to port all of our existing stuff from Joomla/Virtuemart to Wordpress/WooCommerce. So far I've got just about everything done with moving over our product ...
0
votes
0answers
35 views

Need to make a “Meta Box” for Post search

I have a theme, where i can associate post with page there is called ( Hubs ) its part of the actually page. I have figure out so much that when i post a news about something, and it have to go into ...
0
votes
1answer
120 views

Storing post_meta fields in array

I need to have 8 separate post meta fields on each post in wp-admin (shown in a custom meta field box). I'd like the data from these 8 fields to be stored in an array as one post_meta field for easy ...