Questions tagged [update-post-meta]
14 questions
2
votes
0 answers
Unable to update Focus keyphrase in woocommerce product category using update_post_meta
I am trying to update yoast focus keyphrase using the code below.
add_action( 'created_product_cat', 'ts_custom_woocommerce_placeholder', 10, 2 );
function ts_custom_woocommerce_placeholder( $post_id ) {
$productname = 'test prduct'
…
2
votes
1 answer
Create a coupon programmatically since WooCommerce 3+
I add coupons at woocommerce with this code programmatically.
if(empty($coupon_post)){
$coupon = array(
'post_title' => $coupon_code,
'post_content' => '',
'post_status' => 'publish',
…

Patrick R.
- 53
- 6
1
vote
0 answers
update_post_meta not saving
I'm a novice so please bear with me. Thank you.
I created 2 custom post types. brands and models.
I created relationship custom fields using acf under brands
The relationship field pulls the posts from models
Inside the models I created custom…

problematic child
- 11
- 2
1
vote
1 answer
PHP: Removing string count of entire array from serialized array
I have a JSON array that I'm saving in a PHP variable. I'm then serializing that array using serialize($variable) and saving it to the dB with the built in Wordpress function update_post_meta().
The problem I'm having is that the entire serialized…

Eric Brockman
- 824
- 2
- 10
- 37
1
vote
2 answers
Correct way to insert serialized data into WordPress Post Meta using update_post_meta
I am trying to insert serialized data into the wp_postmeta table using the update_post_meta function.
However when I insert the data into the table, it is being changed. For example, here is what I am trying to insert:
update_post_meta($feed_id,…

Zach Nicodemous
- 9,097
- 9
- 45
- 68
0
votes
2 answers
Update Post Meta of all published posts to show current date
How can I Update Post Meta of all my published posts in WordPress to show current date and time each time any visitor click the post? Like a custom code in theme function to modify the the single post page to show visitor's current date and time at…
0
votes
1 answer
Programatically set "post_parent" using variable in "wp_update_post" argument
So let me start with in a nutshell, my application has the user submit a form which then creates a post and populates some custom fields (I am using fieldmanager). one of the fields on the form is a select that contains a list of the posts already…

Cal Hart
- 9
- 2
0
votes
0 answers
wp_postmeta - repeating custom field
can somebody help me?
Im using WCK plugin and I need to pass my values to repeating field.
here is my code:
if (isset($_POST["ada_cost_but_naklad"])) {
$nazevNakladu = $_POST["nazevNakladu"] ;
$cenaNakladu =…

Adko
- 23
- 6
0
votes
1 answer
Automatically update ACF field upon date
Here is what I am trying to accomplish: turn off a True/False Advanced Custom Fields(ACF) option on a post if the current date is on or past a selected date on the same post. Also after that code, turn off a Sample Lesson True/False option inside of…

iamgroot
- 21
- 6
0
votes
2 answers
How to delete values of a wordpress post_meta_value
everyone
I would like to delete a value from the postmeta in my wordpress installation - and not a complete metavalue, but only part of the content in it.
e.g. metakey = test
metavalue = abba; dancing; queen;
and the "dancing" should be thrown…

JSt.
- 1
- 1
0
votes
1 answer
How to get the number of visits to an article in 24 hours?
I use this function to save article views
function wpb_set_post_views($postID) {
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
…

jimi-del
- 93
- 1
- 11
0
votes
2 answers
Wordpres Cron Jobs - Changing post meta after set time
I'm having trouble getting a cron job working in wordpress.
Setup:
I have a custom post type ('jobs') that have a couple of meta fields:
'featured' (bool) set to true if it is featured and
'feature-expiry' (DateTime) which is the time that the…

Steven Jupiter
- 11
- 3
0
votes
2 answers
Problem with add_post_meta() function in Wordpress
When a use it like this:
add_post_meta($post_ID, 'Name', "Bob", true );
works fine, but when a store an string value inside a variable, for example:
$name = "Bob";
add_post_meta($post_ID, 'Name', $name, true ); // <---- This doesn't work.
Some…

ecv86
- 1
0
votes
1 answer
Updating a field with a function in wordpress
I'm trying to code a function that will automatically tick a check box field in the back-end when the post status is set to 'publish'. This is in my functions.php btw.
function featured_post(){
if( get_post_status() == 'publish'…

michael74
- 3
- 2