在您发布/更新帖子时,请使用price
, 最好有另一个自定义元帖子来保存real price
在it中使用add_action() 和add_post_meta(), 然后,您可以使用您发布的查询,但$query_args[\'meta_key\'] = \'real_price\';
如下所示:
function wp_po54785( $post_id )
{
$recommended_price = get_post_meta( $post_id, \'price\', true );
if ( ! $recommended_price )
return;
// Avoid infinite loops
remove_action( current_filter(), __FUNCTION__ );
// If you\'re doing this from inside a class:
# remove_action( current_filter(), array( $this, __FUNCTION__ ) );
// The Algorithm
// You use to
// Calculate real price
// By doing works on $recommended_price
// And put in $real_price;
add_post_meta( $post_id, \'real_price\', $real_price );
}
add_action( \'save_post\', \'wp_po54785\' );