I am trying to edit how the value of a custom meta boxes is display to my WordPress post edit page. I’m using a plugin this pulling the listings for the IDX, however, it’s pulling the price with currency symbol and commas. I want it to be numbers only on WordPress post edit page.
This is the code I wrote based on what I saw with the plugin code, but nothing is happening.
function listing_details_metabox() {
wp_nonce_field( 'wp_listings_metabox_save', 'wp_listings_metabox_nonce' );
global $post;
$property_details = $_POST['wp_listings'];
if ( null == $post_id ) {
global $post;
$post_id = $post->ID;
}
$price = preg_replace('/[^0-9.]/', '', get_post_meta( $post_id, '_listing_price', true));
if ( ! isset( $property_details['col1']['_listing_price'] ) ) {
?>
<p>
<label for="wp_listings[_listing_price]" >Price 2</label>
<input type="text" name="wp_listings[_listing_price]" value="<?php if ( isset ( $price ) ) echo $price; ?>"$
</p>
<?php
}
}
enter image description here
Walker R. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1