query – Can a filter be applied to meta return value data when querying posts?

I query my posts and apply the price order by sorting the filters below.

But mine product_price_from The metafield contains a number that is entered in different currencies. GBP, USD, AED etc. As the suppliers come from different parts of the world.

I calculate this data live in an AED in a currency at the front end of the website using live exchange rates. So that the prices do not have to be updated with every currency change.

Here is my example of a sort query …

/**
 * product archive filters
 * @return array
 */
public static function filters() {

    // determine our sorting filters
    switch(self::$sorting) {

        case 'price_highest':
            $filters('meta_key')   = 'product_price_from';
            $filters('orderby')    = 'meta_value_num';
            $filters('order')      = 'DESC';
            break;

        case 'price_lowest':
            $filters('meta_key')   = 'product_price_from';
            $filters('orderby')    = 'meta_value_num';
            $filters('order')      = 'ASC';
            break;

        case 'latest':
        default:
            $filters('orderby')    = 'date';
            $filters('order')      = 'DESC';
            break;

    }

    return $filters;

}

Since the numerical values ​​vary depending on the exchange rate, the results for the order according to price are incorrect.

My question is any kind of meta_key Filter that I can apply to the retrieved value before it is applied to the query.

For example, I would have to use a function like this … toAED($post_id,$value,$currency); to product_price_from Meta value in the query.

Is it possible with WordPress Query?

ajax – Custom meta box (SELECT2) with wrong taxonomy tag

I updated this code. Category taxonomy works fine, but tag taxonomy doesn't.

/*
 * Add a metabox
 * I hope you're familiar with add_meta_box() function, so, nothing new for you here
 */
add_action( 'admin_menu', 'rudr_metabox_for_select2_tags' );
function rudr_metabox_for_select2_tags() {
    add_meta_box( 'rudr_select1', 'Tune Tags', 'rudr_display_select2_tag_metabox', 'post', 'side', 'low' );
}
/*
 * Display the fields inside it
 */
function rudr_display_select2_tag_metabox( $post_object ) {
    // I decided to write all the metabox html into a variable and then echo it at the end
    $html = '';

    // always array because we have added () to our ';
        foreach( $tags as $tag ) {
            $selected = ( is_array( $appended_tag ) && in_array( $tag->term_id, $appended_tag ) ) ? ' selected="selected"' : '';
            $html .= '';
        }
        $html .= ' name attribute
    $appended_cat = get_post_meta( $post_object->ID, 'rudr_select2_cat',true ); 
    /*
     * It will be just a multiple select for tags without AJAX search
     * If no tags found - do not display anything
     * hide_empty=0 means to show tags not attached to any posts
     */
    if( $cats = get_terms( 'category', 'hide_empty=0' ) ) {
        $html .= '

'; } echo $html; } add_action( 'wp_ajax_mishagetcat', 'rudr_get_cat_ajax_callback' ); // wp_ajax_{action} function rudr_get_cat_ajax_callback(){ // we will pass post IDs and titles to this array $return = array(); $cat = get_terms( array('taxonomy' => 'category','search'=> $_GET('q'),'ignore_sticky_posts' => 1,)); foreach ( $cat as $cat ) { // shorten the title a little $title = ( mb_strlen( $cat->name ) > 50 ) ? mb_substr( $cat->name, 0, 49 ) . '...' : $cat->name; $return() = array( $cat->term_id, $title ); // array( Post ID, Post Title ) } echo json_encode( $return ); die; } //auto_save add_action( 'save_post', 'rudr_save_metaboxdata', 10, 2 ); function rudr_save_metaboxdata( $post_id, $post ) { if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id; // if post type is different from our selected one, do nothing if ( $post->post_type == 'post' ) { if( isset( $_POST('rudr_select2_cat') ) ) update_post_meta( $post_id, 'rudr_select2_cat', $_POST('rudr_select2_cat') ); else delete_post_meta( $post_id, 'rudr_select2_cat' ); if( isset( $_POST('rudr_select2_tags') ) ) update_post_meta( $post_id, 'rudr_select2_tags', $_POST('rudr_select2_tags') ); else delete_post_meta( $post_id, 'rudr_select2_tags' ); } return $post_id; } //add_script_&_stylesheet add_action( 'admin_enqueue_scripts', 'rudr_select2_enqueue' ); function rudr_select2_enqueue(){ wp_enqueue_style('select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css' ); wp_enqueue_script('select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js', array('jquery') ); // please create also an empty JS file in your theme directory and include it too wp_enqueue_script('mycustom', get_template_directory_uri() . '/css/mycustom.js', array( 'jquery', 'select2' ) ); }

Enter image description here
But only show deaf category.

WordPress hook for post content and meta update

I want to update and redirect and use one of my meta fields post_updatedHook. Here is my code.

function job_publish_status( $post_ID, $post_after, $post_before ) {
   $job_published_date = get_the_time("Y-m-d", $post_ID);
   $expire_date = date('Y-m-d', strtotime($job_published_date. ' + 60 days'));
   update_post_meta($post_ID, '_job_expires', $expire_date);
   $url = get_site_url();
   $url = $url.'/wp-admin/post.php?post='.$post_ID.'&action=edit';
   wp_redirect( $url );
   exit; 
}
add_action('post_updated', 'job_publish_status', 99, 3 );

It updates this _job_expires Metafield and forwarding correct. When I edit the content and title of a post, the title and content of the post are updated, but other meta fields in this post are not updated.
Is there a tick that is triggered after the content is updated and the meta fields are updated?