0

I want to clarify that I am not a specialist, my query is how to insert a metabox in the front end, specifically I show you the image:

I want to do this: I want to do this

But actually I have this:

Actually I have this

Those are the php codes:

framework/metaboxes/property/multi_units.php

/**
 * Add multi_units metabox tab
 *
 * @param $metabox_tabs
 *
 * @return array
 */
function houzez_multi_units_metabox_tab( $metabox_tabs ) {
    if ( is_array( $metabox_tabs ) ) {

        $metabox_tabs['multi_units'] = array(
            'label' => houzez_option('cls_sub_listings', 'Sub Listings'),
            'icon' => 'dashicons-layout',
        );

    }
    return $metabox_tabs;
}
add_filter( 'houzez_property_metabox_tabs', 'houzez_multi_units_metabox_tab', 61 );


/**
 * Add multi_units metaboxes fields
 *
 * @param $metabox_fields
 *
 * @return array
 */
function houzez_multi_units_metabox_fields( $metabox_fields ) {
    $houzez_prefix = 'fave_';

    $fields = array(
        array(
            'id' => "{$houzez_prefix}multi_units_ids",
            'name' => houzez_option('cl_subl_ids', 'Listing IDs'),
            'placeholder' => houzez_option('cl_subl_ids_plac', 'Enter the listing IDs comma separated'),
            'desc' => houzez_option('cl_subl_ids_tooltip', 'If the sub-properties are separated listings, use the box above to enter the listing IDs (Example: 4,5,6)'),
            'type' => 'textarea',
            'columns' => 12,
            'tab' => 'multi_units',
        ),
        array(
            'type' => 'heading',
            'name' => houzez_option('cl_or', 'Or'),
            'columns' => 12,
            'desc' => "",
            'tab' => 'multi_units',
        ),
        array(
            'id'     => "{$houzez_prefix}multi_units",
            // Gropu field
            'type'   => 'group',
            // Clone whole group?
            'clone'  => true,
            'sort_clone' => false,
            'tab' => 'multi_units',
            // Sub-fields
            'fields' => array(
                array(
                    'name' => houzez_option('cl_subl_title', 'Title' ),
                    'id'   => "{$houzez_prefix}mu_title",
                    'type' => 'text',
                    'placeholder' => houzez_option('cl_subl_title_plac', 'Enter the title'),
                    'columns' => 12,
                ),
                array(
                    'name' => houzez_option('cl_subl_price', 'Price' ),
                    'id'   => "{$houzez_prefix}mu_price",
                    'placeholder' => houzez_option('cl_subl_price_plac', 'Enter the price'),
                    'type' => 'text',
                    'columns' => 6,
                ),
                array(
                    'name' => houzez_option('cl_subl_price_postfix', 'Price Postfix' ),
                    'id'   => "{$houzez_prefix}mu_price_postfix",
                    'placeholder' => houzez_option('cl_subl_price_postfix_plac', 'Enter the price postfix'),
                    'type' => 'text',
                    'columns' => 6,
                ),
                array(
                    'name' => houzez_option('cl_subl_bedrooms', 'Bedrooms' ),
                    'id'   => "{$houzez_prefix}mu_beds",
                    'placeholder' => houzez_option('cl_subl_bedrooms', 'Enter the number of bedrooms'),
                    'type' => 'text',
                    'columns' => 6,
                ),
                array(
                    'name' => houzez_option('cl_subl_bathrooms', 'Bathrooms' ),
                    'id'   => "{$houzez_prefix}mu_baths",
                    'placeholder' => houzez_option('cl_subl_bathrooms_plac', 'Enter the number of bathrooms'),
                    'type' => 'text',
                    'columns' => 6,
                ),
                array(
                    'name' => houzez_option('cl_subl_size', 'Property Size' ),
                    'id'   => "{$houzez_prefix}mu_size",
                    'placeholder' => houzez_option('cl_subl_size', 'Enter the property size'),
                    'type' => 'text',
                    'columns' => 6,
                ),
                array(
                    'name' => houzez_option('cl_subl_size_postfix', 'Size Postfix' ),
                    'id'   => "{$houzez_prefix}mu_size_postfix",
                    'placeholder' => houzez_option('cl_subl_size_postfix_plac', 'Enter the property size postfix'),
                    'type' => 'text',
                    'columns' => 6,
                ),
                array(
                    'name' => houzez_option('cl_subl_type', 'Property Type' ),
                    'id'   => "{$houzez_prefix}mu_type",
                    'placeholder' => houzez_option('cl_subl_type_plac', 'Enter the property type'),
                    'type' => 'text',
                    'columns' => 6,
                ),
                array(
                    'name' => houzez_option('cl_subl_date', 'Availability Date' ),
                    'id'   => "{$houzez_prefix}mu_availability_date",
                    'placeholder' => houzez_option('cl_subl_date_plac', 'Enter the availability date'),
                    'type' => 'text',
                    'columns' => 6,
                ),

            ),
        ),
    );

    return array_merge( $metabox_fields, $fields );

}
add_filter( 'houzez_property_metabox_fields', 'houzez_multi_units_metabox_fields', 61 );

template-parts/dashboard/submit/sub-properties.php

<div id="sub-properties" class="dashboard-content-block-wrap <?php echo esc_attr($is_multi_steps);?>">
    <h2><?php echo houzez_option('cls_sub_listings', 'Sub Listings'); ?></h2>
    <div class="dashboard-content-block">
        <div id="multi_units_main">
            <?php 
            $data_increment = 0;
            if(houzez_edit_property()) { 
            global $property_data;
            $multi_units = get_post_meta( $property_data->ID, 'fave_multi_units', false );
            $count = 0;
                if( !empty($multi_units) ) {
                foreach ($multi_units as $multi_unit):
            ?>
            <div class="houzez-units-clone">
                <div class="row">
                    <div class="col-md-12 col-sm-12">
                        <div class="remove-subproperty-row" data-remove="<?php echo esc_attr( $count-1 ); ?>">
                            <i class="houzez-icon icon-remove-circle mr-2"></i>
                        </div>
                        <div class="form-group">
                            <label for="fave_multi_units[<?php echo intval($count); ?>][fave_mu_title]"><?php echo houzez_option('cl_subl_title', 'Title' ); ?></label>
                            <input value="<?php echo sanitize_text_field( $multi_unit['fave_mu_title'] ); ?>" name="fave_multi_units[<?php echo intval($count); ?>][fave_mu_title]" type="text" class="form-control" placeholder="<?php echo houzez_option('cl_subl_title_plac', 'Enter the title');?>">
                        </div>
                    </div><!-- col-md-12 col-sm-12 -->
                    <div class="col-md-6 col-sm-12">
                        <div class="form-group">
                            <label for="fave_multi_units[<?php echo intval($count); ?>][fave_mu_beds]"><?php echo houzez_option('cl_subl_bedrooms', 'Bedrooms' ); ?></label>
                            <input value="<?php echo sanitize_text_field( $multi_unit['fave_mu_beds'] ); ?>" name="fave_multi_units[<?php echo intval($count); ?>][fave_mu_beds]" type="text" class="form-control" placeholder="<?php echo houzez_option('cl_subl_bedrooms', 'Enter the number of bedrooms');?>">
                            <small class="form-text text-muted"><?php esc_html_e('Only digits', 'houzez'); ?></small>
                        </div>
                    </div><!-- col-md-6 col-sm-12 -->
                    <div class="col-md-6 col-sm-12">
                        <div class="form-group">
                            <label for="fave_multi_units[<?php echo intval($count); ?>][fave_mu_baths]"><?php echo houzez_option('cl_subl_bathrooms', 'Bathrooms' ); ?></label>
                            <input value="<?php echo sanitize_text_field( $multi_unit['fave_mu_baths'] ); ?>" name="fave_multi_units[<?php echo intval($count); ?>][fave_mu_baths]" type="text" class="form-control" placeholder="<?php echo houzez_option('cl_subl_bathrooms_plac', 'Enter the number of bathrooms');?>">
                            <small class="form-text text-muted"><?php esc_html_e('Only digits', 'houzez'); ?></small>
                        </div>
                    </div><!-- col-md-6 col-sm-12 -->
                    <div class="col-md-6 col-sm-12">
                        <div class="form-group">
                            <label for="fave_multi_units[<?php echo intval($count); ?>][fave_mu_size]"><?php echo houzez_option('cl_subl_size', 'Property Size' ); ?></label>
                            <input value="<?php echo sanitize_text_field( $multi_unit['fave_mu_size'] ); ?>" name="fave_multi_units[<?php echo intval($count); ?>][fave_mu_size]" type="text" class="form-control" placeholder="<?php echo houzez_option('cl_subl_size', 'Enter the property size');?>">
                        </div>
                    </div><!-- col-md-6 col-sm-12 -->
                    <div class="col-md-6 col-sm-12">
                        <div class="form-group">
                            <label for="fave_multi_units[<?php echo intval($count); ?>][fave_mu_size_postfix]"><?php echo houzez_option('cl_subl_size_postfix', 'Size Postfix' ); ?></label>
                            <input value="<?php echo sanitize_text_field( $multi_unit['fave_mu_size_postfix'] ); ?>" name="fave_multi_units[<?php echo intval($count); ?>][fave_mu_size_postfix]" type="text" class="form-control" placeholder="<?php echo houzez_option('cl_subl_size_postfix_plac', 'Enter the property size postfix');?>">
                        </div>
                    </div><!-- col-md-6 col-sm-12 -->
                    
                    <div class="col-md-6 col-sm-12">
                        <div class="form-group">
                            <label for="fave_multi_units[<?php echo intval($count); ?>][fave_mu_price]"><?php echo houzez_option('cl_subl_price', 'Price' ); ?></label>
                            <input value="<?php echo sanitize_text_field( $multi_unit['fave_mu_price'] ); ?>" name="fave_multi_units[<?php echo intval($count); ?>][fave_mu_price]" type="text" class="form-control" placeholder="<?php echo houzez_option('cl_subl_price_plac', 'Enter the price');?>">
                            
                        </div>
                    </div><!-- col-md-6 col-sm-12 -->
                    <div class="col-md-6 col-sm-12">
                        <div class="form-group">
                            <label for="fave_multi_units[<?php echo intval($count); ?>][fave_mu_price_postfix]"><?php echo houzez_option('cl_subl_price_postfix', 'Price Postfix' ); ?></label>
                            <input value="<?php echo sanitize_text_field( $multi_unit['fave_mu_price_postfix'] ); ?>" name="fave_multi_units[<?php echo intval($count); ?>][fave_mu_price_postfix]" type="text" class="form-control" placeholder="<?php echo houzez_option('cl_subl_price_postfix_plac', 'Enter the price postfix');?>">
                        </div>
                    </div><!-- col-md-6 col-sm-12 -->

                    <div class="col-md-6 col-sm-12">
                        <div class="form-group">
                            <label for="fave_multi_units[<?php echo intval($count); ?>][fave_mu_type]"><?php echo houzez_option('cl_subl_type', 'Property Type' ); ?></label>
                            <input value="<?php echo sanitize_text_field( $multi_unit['fave_mu_type'] ); ?>" name="fave_multi_units[<?php echo intval($count); ?>][fave_mu_type]" type="text" class="form-control" placeholder="<?php echo houzez_option('cl_subl_type_plac', 'Enter the property type');?>">
                        </div>
                    </div>
                    <div class="col-md-6 col-sm-12">
                        <label for="fave_multi_units[<?php echo intval($count); ?>][fave_mu_availability_date]"><?php echo houzez_option('cl_subl_date', 'Availability Date' ); ?></label>
                        <input value="<?php echo sanitize_text_field( $multi_unit['fave_mu_availability_date'] ); ?>" name="fave_multi_units[<?php echo intval($count); ?>][fave_mu_availability_date]" type="text" class="form-control" placeholder="<?php echo houzez_option('cl_subl_date_plac', 'Enter the availability date');?>">
                    </div>
                </div><!-- row -->
                <hr>
            </div>
            <?php 
                $count++;
                endforeach;
                $data_increment = $count - 1;
                }
            } else { ?>
            <div class="houzez-units-clone">
                <div class="row">
                    <div class="col-md-12 col-sm-12">
                        <div class="remove-subproperty-row" data-remove="0">
                            <i class="houzez-icon icon-remove-circle mr-2"></i>
                        </div>
                        <div class="form-group">
                            <label for="fave_multi_units[0][fave_mu_title]"><?php echo houzez_option('cl_subl_title', 'Title' ); ?></label>
                            <input name="fave_multi_units[0][fave_mu_title]" type="text" class="form-control" placeholder="<?php echo houzez_option('cl_subl_title_plac', 'Enter the title');?>">
                        </div>
                    </div><!-- col-md-12 col-sm-12 -->
                    <div class="col-md-6 col-sm-12">
                        <div class="form-group">
                            <label for="fave_multi_units[0][fave_mu_beds]"><?php echo houzez_option('cl_subl_bedrooms', 'Bedrooms' ); ?></label>
                            <input name="fave_multi_units[0][fave_mu_beds]" type="text" class="form-control" placeholder="<?php echo houzez_option('cl_subl_bedrooms', 'Enter the number of bedrooms');?>">
                        </div>
                    </div><!-- col-md-6 col-sm-12 -->
                    <div class="col-md-6 col-sm-12">
                        <div class="form-group">
                            <label for="fave_multi_units[0][fave_mu_baths]"><?php echo houzez_option('cl_subl_bathrooms', 'Bathrooms' ); ?></label>
                            <input name="fave_multi_units[0][fave_mu_baths]" type="text" class="form-control" placeholder="<?php echo houzez_option('cl_subl_bathrooms_plac', 'Enter the number of bathrooms');?>">
                        </div>
                    </div><!-- col-md-6 col-sm-12 -->
                    <div class="col-md-6 col-sm-12">
                        <div class="form-group">
                            <label for="fave_multi_units[0][fave_mu_size]"><?php echo houzez_option('cl_subl_size', 'Property Size' ); ?></label>
                            <input name="fave_multi_units[0][fave_mu_size]" type="text" class="form-control" placeholder="<?php echo houzez_option('cl_subl_size', 'Enter the property size');?>">
                        </div>
                    </div><!-- col-md-6 col-sm-12 -->
                    <div class="col-md-6 col-sm-12">
                        <div class="form-group">
                            <label for="fave_multi_units[0][fave_mu_size_postfix]"><?php echo houzez_option('cl_subl_size_postfix', 'Size Postfix' ); ?></label>
                            <input name="fave_multi_units[0][fave_mu_size_postfix]" type="text" class="form-control" placeholder="<?php echo houzez_option('cl_subl_size_postfix_plac', 'Enter the property size postfix');?>">
                        </div>
                    </div><!-- col-md-6 col-sm-12 -->
                    
                    <div class="col-md-6 col-sm-12">
                        <div class="form-group">
                            <label for="fave_multi_units[0][fave_mu_price]"><?php echo houzez_option('cl_subl_price', 'Price' ); ?></label>
                            <input name="fave_multi_units[0][fave_mu_price]" type="text" class="form-control" placeholder="<?php echo houzez_option('cl_subl_price_plac', 'Enter the price');?>">
                            <small class="form-text text-muted"><?php esc_html_e('Only digits', 'houzez'); ?></small>
                        </div>
                    </div><!-- col-md-6 col-sm-12 -->
                    <div class="col-md-6 col-sm-12">
                        <div class="form-group">
                            <label for="fave_multi_units[0][fave_mu_price_postfix]"><?php echo houzez_option('cl_subl_price_postfix', 'Price Postfix' ); ?></label>
                            <input name="fave_multi_units[0][fave_mu_price_postfix]" type="text" class="form-control" placeholder="<?php echo houzez_option('cl_subl_price_postfix_plac', 'Enter the price postfix');?>">
                        </div>
                    </div><!-- col-md-6 col-sm-12 -->

                    <div class="col-md-6 col-sm-12">
                        <div class="form-group">
                            <label for="fave_multi_units[0][fave_mu_type]"><?php echo houzez_option('cl_subl_type', 'Property Type' ); ?></label>
                            <input name="fave_multi_units[0][fave_mu_type]" type="text" class="form-control" placeholder="<?php echo houzez_option('cl_subl_type_plac', 'Enter the property type');?>">
                        </div>
                    </div>
                    <div class="col-md-6 col-sm-12">
                        <div class="form-group">
                            <label for="fave_multi_units[0][fave_mu_availability_date]"><?php echo houzez_option('cl_subl_date', 'Availability Date' ); ?></label>
                            <input name="fave_multi_units[0][fave_mu_availability_date]" type="text" class="form-control" placeholder="<?php echo houzez_option('cl_subl_date_plac', 'Enter the availability date');?>">
                        </div>
                    </div>
                </div><!-- row -->
                <hr>
            </div>
            <?php } ?>
        </div>

        <button id="add-subproperty-row" data-increment="<?php echo esc_attr($data_increment); ?>" class="btn btn-primary btn-left-icon"><i class="houzez-icon icon-add-circle"></i> <?php esc_html_e('Add New', 'houzez'); ?></button>
    </div><!-- dashboard-content-block -->
</div><!-- dashboard-content-block-wrap -->

As you can see, the php "template-parts / dashboard / submit / sub-properties.php" does not include the LISTING IDs option of the php "framework / metaboxes / property / multi_units.php", which is finally the one I need

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.