I have a custom field value called points.

  • Post 01 points = 5
  • Post 02 points = 10
  • Post 03 points = 8

I need to create another custom filed value called rank.

Rank custom filed value should be like this.

  • Post 01 rank : 1
  • Post 02 rank : 3
  • Post 03 rank : 2

It is totally based on other custom filed value. It should be change every time when point custom filed value change.

Is it possible or there is an alternative way to do it?

PS : Basically what I need to do it when a post view I need to display according to points this is a 5th post.... like wise...

1 Answer 1


I recommend you look into the get_{$meta_type}_metadata filter. This is a basic hook setup to return a dynamic post meta value:

add_filter( "get_post_metadata", function( $points, $post_id, $meta_key, $single ){
    if ( 'points' == $meta_key && $single ) {
        update_post_meta( $post_id, 'rank', calculate_post_rank( $post_id, $points ) );

    return $points;
}, 10, 4 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.