0

I have a function to update the post meta for a post. Is it possible to perform this function and update the meta key so that when the post is displayed, the meta key has already been updated?

So update meta key before post display.

Tom Harisond
  • 57
  • 1
  • 10

1 Answers1

0

You can try the following

function change_my_meta_value($value, $post_id, $meta_key, $single) {
    $value = your_function_to_change_value(); // Change the value and store in database
    return $value; // return the new value.
}

add_filters( "get_METANAME_metadata", 'change_my_meta_value', 10, 4 );

You have to change METANAME with your actual meta name.

VA79
  • 474
  • 3
  • 7