The tag has no wiki summary.

learn more… | top users | synonyms

8
votes
1answer
1k views

Why are simple updates to wp_postmeta's “_edit_lock” so slow?

In our MySQL slow query log, the cumulatively slowest query is a simple update to wp_postmeta. Here's an example: UPDATE `wp_postmeta` SET `meta_value` = '1392835505:386' WHERE `post_id` = 94705 ...
4
votes
1answer
346 views

Code to make a post sticky

How is it possible to upgrade a post to make it sticky directly from code, not by admin area? Is it possible through a code like: update_post_meta($post_id, $meta_key, $meta_value, $prev_value); In ...
3
votes
1answer
5k views

How to save an array with one metakey in postmeta?

I have an array saved in postmata, each array key become a metakey. I want to change the code to save the whole array with one metakey. How to do that? Thanks! $poddata = Array( 'pod_id' => ...
3
votes
2answers
1k views

Custom Post type - how to get checkbox to update meta field to null

I have 7 meta fields for a custom post type in Wordpress. These 7 in particular are days of the week (Sunday thru Saturday) and have checkboxes for each. I've successfully gotten the checkbox to POST ...
3
votes
2answers
1k views

Custom field values deleted when trashing custom post type

I've created a custom post type with 2 custom fields attached to it... When I create a post of this type and fill in the custom fields, the data is, in fact, saved to the db... However, if I trash one ...
3
votes
2answers
289 views

update_post_meta not saving when value is zero

I have a problem with the update_post_meta function. I have a user submitted value, which I pass via $_POST and then saving to post meta. All is working fine, but when the value is '0' the post meta ...
3
votes
1answer
244 views

Storing meta fields multiple times OR once with multi dimensional array?

I got some options that I expand using a repeater type field. The values I save for each field is already an array so in essence I'm saving a multi dimentional array per option. (See this weekly ...
2
votes
1answer
547 views

How to update/delete array in post meta value?

I using post meta like.. $meta = get_post_meta(99,'_mymeta',true); $value = $meta['somekey']; echo $value; But how to update $meta['somekey'] to some another value ? How to use update_post_meta to ...
2
votes
1answer
1k views

Inserting Hundreds of Thousands of Posts at Once

I have a project in which I create an array of 200k+ lines w/ 25 fields that run the wp_insert_post and update_post_meta. To start it processes pretty fast the slows down a lot after 10k records or ...
2
votes
1answer
750 views

Use ajax to update_post_meta

2 days ago I asked this then I tried to work on my code to be able to understand how ajax and php work and now I have a new issue that, probably would be easily solved. These are my codes: <?php ...
2
votes
1answer
42 views

How to use update_{$meta_type}_metadata filter to modify meta value

I'm trying to wrap my head around the update_{$meta_type}_metadata filter, in order to modify both post and user metadata before database insertion. After reading the docs and the core, it seems to ...
2
votes
1answer
268 views

Unable to save datetime custom meta field using update_post_meta() function

When I do something like this (in my plugin function inside WP admin): $metaboxes = get_post_meta( $post_id ); echo "<pre>"; print_r($metaboxes); echo "</pre>"; die(); I get all my ...
2
votes
0answers
341 views

Copying Custom Meta Values from existing post to a duplicate post

I'm trying to revise an existing WP plugin BU Versions to accept different custom meta field values from items I've set-up using the Advanced Custom Fields (ACF) plugin. BU Versions will copy over ...
1
vote
1answer
389 views

Change post thumbnail using front end post edit form

I'm trying to get the post thumbnail to change if a user selects a new file on a front end post edit screen. This is similar to the code I use to upload data and set the post thumbnail on a front end ...
1
vote
2answers
2k views

Custom Post Type, Saving Multiple Checkboxes

For a custom post type, I'm pulling in a list of another custom post types that I need to select for saving ... <input type="checkbox" name="32"> My CPT <br> <input type="checkbox" ...
1
vote
3answers
571 views

Change the post date from a meta box

I'm having a problem with updating the post_date in a custom function I've written. I'm trying to change the "post_date" to my custom "meta_date" value. Here is the function: function ...
1
vote
1answer
54 views

Setting post meta data to random value during post status transition / on publish

Upon publishing an unpublished draft, I'd like the custom meta value "post views count" to be set to a random variable between 829 and 1013. I am using the code below, which doesn't always work. It ...
1
vote
1answer
26 views

Save re-arranged draggable post items to wordpress database

So i've followed the clearly documented pages for the packery and the draggabilly plugins to allow for a customizable grid and looked at how localStorage can be used to remember/store data of the ...
1
vote
1answer
79 views

update_post_meta and get_post_meta not working

I am trying to get the input from a textbox and display it upon update. I don't know if the update_post_meta or get_post_meta is causing the problem. Code //Metabox Hook ...
1
vote
1answer
743 views

Change post_date to post_modified date on post template?

I'm looking to change the post created date to a modified date on my post template (single.php). Moreso, I'm looking to control when I update that date based on whether I make significant changes to ...
1
vote
2answers
4k views

How to use wp_insert_post to update meta box?

I'm trying to use wp_insert_post to create a front-end submission form so visitors can create a post AND update the meta box fields of that post -- not the custom fields. For example, when I use the ...
1
vote
1answer
630 views

Custom Post Type: Set post_title equal to a custom post type field

I’ve created a custom post type for employees in a company with some fields they have to fill (like E-mail, phone, etc.) and a select box which takes some values from another custom post type called ...
1
vote
1answer
67 views

wp_insert_post() getting slower the more posts

I have written a bulk import script where I import posts with the wp_insert_post() function and add 1 meta value and 1 term to the post. I have done 6 times of 7000 posts now, but for some reason the ...
1
vote
1answer
1k views

update_post_meta() whenever custom post type is updated

I need the following functionality. Whenever my custom post type is updated or saved I need to overwrite certain custom post metas. I need to make sure this only affects posts of the post type ...
1
vote
1answer
164 views

How to use update_post_meta inside wp_trash_post

I have some metadata on my post edit page that saves perfectly using the hook and function below: add_action('save_post', 'save_meta_data'); function save_meta_data($post_id){ ...
1
vote
1answer
422 views

Update post meta on bulk edit / update

I have a small problem with a code that works most of the time. I just discovered it cannot be used when I bulk edit custom post type. If I'm on individual post page and hit publish, the custom post ...
1
vote
1answer
750 views

“update_post_meta” not working in “wp_insert_post_data” hook

I have created the following hook in my functions.php add_filter('wp_insert_post_data', 'ad_change_title'); function ad_change_title($data) { if($data['post_type'] != 'ad_listing') ...
1
vote
1answer
546 views

update_post_meta, xml parser

I'm hitting the wall for nearly two hours now, trying to figure this out. Here is the thing' I have made a xml parser to read xml file and add posts (with content) from xml: $ch = curl_init( ...
1
vote
1answer
34 views

WordPress update_post_meta updating with empty meta_value field [closed]

I'm usuing custom fields pluging and my code has to fill them automitcally, everything works fine except 2 strings: The way i'm getting the fields: foreach($postMeta as $key => $dataTmp) ...
1
vote
0answers
170 views

How to save double quotes in post meta, when the post meta data is an array? [closed]

Ok so I've been scratching my head on this one for a while. I'm making a plugin that adds a custom meta box to a custom post type. I'm using the update_post_meta function to save the data from the ...
1
vote
0answers
283 views

Bulk update all posts from plugin settings screen

I'm writing a plugin right now that will populate custom metadata for all posts on the site based on a certain rule. I've already created a Plugin's settings page and a logic that should be triggered ...
1
vote
0answers
61 views

How to prevent further updates of custom meta when using actions to set one meta based on another

I'm using rilwis' Meta Box plugin (see https://github.com/rilwis/meta-box) to add custom meta boxes to a custom post type. I then want to populate one piece of meta data based on the value of ...
1
vote
0answers
152 views

Save modified Custom Field content into another Custom Field on article save [closed]

In my articles I allow editors to enter a date in a human readable dd.mm.yyyy format into a custom field. But I also need this date as unix timestamp in the DB. So I wrote a function which takes the ...
1
vote
3answers
496 views

Saving custom fields to a custom taxonomy

I am trying to create a custom field for a custom taxonomy. update_post_meta works great with posts. Taxonomies are not posts so this won't work. <?php update_post_meta($post_id, $meta_key, ...
0
votes
2answers
89 views

What Is meta_id In wp_postmeta?

I am trying to add some data in WordPress Custom Field and via adding more direct records/data in wp_postmeta table via SQL query. There are four column as mentioned below... 'meta_id' - A unique id ...
0
votes
3answers
265 views

Using preg_replace to filter custom textarea

I am developing a custom post type, which, among others includes the possibility of sending an email from within the post editor. The email body textarea is populated through a custom settings page ...
0
votes
3answers
1k views

How to create a button click counter meta box?

I am trying to create button click counter meta box in a custom post type, but I can't get it to work. What I want to do is when a user click the submit button, then it will do update_post_meta in the ...
0
votes
2answers
255 views

Custom Post type forgetting data

I just set up a custom post type, mostly following this tutorial. I'm setting up things on my site now, doing a lot of CSS modifications and such, and every few minutes the post just forgets ...
0
votes
1answer
1k views

update_post_meta and update_field ony working when saving the post

I use Advanced Custom Fields (ACF) to store data in a custom field. I had latitude and longitude information stored separately, but I they need to be in one custom field so I made the function below. ...
0
votes
1answer
365 views

Change wordpress meta tag description using WP functions

I do apprecciate this may sound like the usual question, but it is not. Just to let you understand I do not need to install one of the many SEO Plugin and change it on the box before content is ...
0
votes
1answer
482 views

update_post_meta only updating on last loop of foreach

I'm building a way to upload multiple files for an announcement custom post type on the front end. My function here uploads any number of files succesfully so I can see them under "Media" in ...
0
votes
1answer
2k views

is there an update_post_meta action

Are there any actions I can hook into for update_post_meta()? I don't see anything obvious in the source. Woocommerce lets you change the featured status of items via ajax from the edit screen. I ...
0
votes
1answer
802 views

What action hook updates post meta?

Is there an straight-forward example anywhere of using wp_update_post() to edit post_meta on the front end? I have not been able to find any good learning resources. What I want to do is display post ...
0
votes
2answers
56 views

Efficient way to update multiple post meta

I have managed to update post meta using update_post_meta(). However, the more posts I have, the more time it takes. I would like to minimize the time it takes to process say about 400 posts (although ...
0
votes
2answers
23 views

Update meta_key value for a page

I have inherited a WP site where some home page slides are pulled using <?php $po = get_posts( array('post_type' => 'page', 'meta_key' => 'Home Slide', 'order' => 'ASC', 'orderby' ...
0
votes
1answer
43 views

wp_update_user isn't instantly?

I'm trying to update a user mail recieved by $_POST and use it instantly. It gets changed, however it outputs the old one. What is the way to do it? global $current_user; get_currentuserinfo(); if ...
0
votes
1answer
117 views

bulk update meta value with ajax

I want to update posts meta value in the wp_query to a different value on click. What I am basically doing is making a notification bubble (like stackoverflow). wp_query with the number of posts ...
0
votes
1answer
293 views

wp_insert_post bulk import 500 server error

I am working on a Wordpress import tool, where I use a custom city table in my database with longitude, latitude which combine with some other text and then import by wp_insert_post(). This works ...
0
votes
1answer
44 views

Custom Post Type not showing anything added by code anymore?

So I have a piece of code written and it worked before, hasn't been edited hasn't been changed, no updates on the WP DB no updates on any plugin on WP and it's suddenly not working correctly. This ...
0
votes
1answer
34 views

Declaring a var, placing it in a query and using the output of the query?

So i'm wondering if it's possible to declare a variable that you'd place in a query to then use it in a update_post_meta function? This is how I tried to do it. First off I made a connection to ...