I am new to this metaboxes.php file, where all the content for the wordpress takes place.
I have a section of Metaboxes.php
array(
'args' => array(
'post_type' => 'xx_property',
'numberposts' => -1,
'post_status' => array(
'publish'
),
),
'data' => 'posts',
'id' => 'xx_realtor',
'multi' => true,
'title' => __( 'view', 'xx_posts' ),
'type' => 'select',
),
Here, this is a select box and select all the realtor who has post_status as publish, but I need to see if the realtor is active or nor. that's in id=xx_active
.
instead of post_status
, I need to point this to saying if the realtor is active show the list.
Can anyone has any suggestions?
Add new meta box for post as a realtor and set this value as active or inactive.
Refer below example code for custom meta box creation,
// Post offer box
add_action( 'add_meta_boxes', 'post_offer' );
function post_offer() {
add_meta_box(
'post_offer',
__( 'Price', 'agrg' ),
'post_offer_content',
'post',
'side',
'high'
);
}
function post_offer_content( $post ) {
wp_nonce_field( 'myplugin_meta_boxeee', 'myplugin_meta_box_nonceeee' );
$post_offer = get_post_meta( $post->ID, 'post_offer', true );
echo '<label for="post_offer"></label>';
echo '<input type="text" id="post_offer" name="post_offer"
placeholder="'._e('Enter price here','agrg').'" value="';
echo $post_offer;
echo '">';
}
add_action( 'save_post', 'post_offer_save' );
function post_offer_save( $post_id ) {
global $post_offer;
if ( ! isset( $_POST['myplugin_meta_box_nonceeee'] ) )
{
return;
}
if ( ! wp_verify_nonce( $_POST['myplugin_meta_box_nonceeee'], 'myplugin_meta_boxeee' ) )
{
return;
}
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
if(isset($_POST["post_offer"]))
$post_offer = $_POST['post_offer'];
update_post_meta( $post_id, 'post_offer', $post_offer );
}