Wordpress Metaboxes.php
我不熟悉这个metaboxes.php文件,wordpress的所有内容都发生在这里 我有一部分Metaboxes.phpWordpress Metaboxes.php,php,wordpress,meta-boxes,Php,Wordpress,Meta Boxes,我不熟悉这个metaboxes.php文件,wordpress的所有内容都发生在这里 我有一部分Metaboxes.php array( 'args' => array( 'post_type' => 'xx_property', 'numberposts' => -1, 'post_status' => array( 'publish' ), ), 'data
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',
),
在这里,这是一个选择框,选择所有具有发布状态的房地产经纪人,但我需要查看房地产经纪人是否处于活动状态。这在id=xx\u active
中
我需要指出的不是post\u status
,而是如果房地产经纪人处于活动状态,则显示列表
有人有什么建议吗?添加新的元框,作为房地产经纪人发布,并将此值设置为活动或非活动 请参阅下面的自定义元框创建示例代码
// 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 );
}
//后报价箱
添加动作(“添加元框”、“发布报价”);
函数post_offer(){
添加元框(
“邮政优惠”,
__(“价格”、“agrg”),
“post_offer_content”,
"岗位",,
"一边",,
“高”
);
}
功能post\u提供内容($post){
wp_nonce_字段('myplugin_meta_boxeee','myplugin_meta_boxeee');
$post\u offer=get\u post\u meta($post->ID,'post\u offer',true);
回声';
回声';
}
添加操作('save_post'、'post_offer_save');
函数post\u offer\u save($post\u id){
全球$post_优惠;
如果(!isset($\u POST['myplugin\u meta\u box\u nonceeee']))
{
返回;
}
如果(!wp\u verify\u nonce($\u POST['myplugin\u meta\u box\u nonceee'],'myplugin\u meta\u boxeee'))
{
返回;
}
if(已定义('DOING_AUTOSAVE')&&DOING_AUTOSAVE){
返回;
}
如果(isset($_POST[“POST_offer”]))
$post_offer=$_post['post_offer'];
更新发布元($post\u id,$post\u offer',$post\u offer);
}
很接近,但我正在处理Redux扩展和post\u类型,其post\u详细信息已编程。。我的代码与此站点类似@Krist所有最佳功能的创建方式都是通过相同的功能完成任何更新/编辑/添加。它在Posteta数据库中得到更新。。或者可以使用条件?编辑post_状态,使用post update hook并获取post的所有值,然后选中元框值,然后您可以根据需要更新post状态。