Custom Additional Information
-
Please help me to add custom information, i add on functions the info to add custom Contato:
add_filter( ‘wpsl_meta_box_fields’, ‘custom_meta_box_fields’ );
function custom_meta_box_fields( $meta_fields ) {
$meta_fields[__( ‘Additional Information’, ‘wpsl’ )] = array(
‘contato’ => array(
‘label’ => __( ‘Contato’, ‘wpsl’ )
),
‘phone’ => array(
‘label’ => __( ‘Tel’, ‘wpsl’ )
),
‘fax’ => array(
‘label’ => __( ‘Fax’, ‘wpsl’ )
),
’email’ => array(
‘label’ => __( ‘Email’, ‘wpsl’ )
),
‘url’ => array(
‘label’ => __( ‘Url’, ‘wpsl’ )
));
return $meta_fields;
}/*Store the custom fields to the DB*/
add_filter( ‘wpsl_frontend_meta_fields’, ‘custom_frontend_meta_fields’ );function custom_frontend_meta_fields( $store_fields ) {
$store_fields[‘contato’] = array(
‘name’ => ‘contato’
);return $store_fields;
}/*Exibir no frontend
add_filter( ‘wpsl_more_info_template’, ‘custom_more_info_template’ );
function custom_more_info_template() {
global $wpsl;
$more_info_template = ‘<% if ( !_.isEmpty( phone ) || !_.isEmpty( fax ) || !_.isEmpty( email ) ) { %>’ . “\r\n”;
$more_info_template .= ‘<p>“>’ . esc_html( $wpsl->i18n->get_translation( ‘more_label’, __( ‘More info’, ‘wpsl’ ) ) ) . ‘</p>’ . “\r\n”;
$more_info_template .= ‘<div id=”wpsl-id-<%= id %>” class=”wpsl-more-info-listings”>’ . “\r\n”;
$more_info_template .= ‘<% if ( description ) { %>’ . “\r\n”;
$more_info_template .= ‘<%= description %>’ . “\r\n”;
$more_info_template .= ‘<% } %>’ . “\r\n”;
$more_info_template .= ‘<p>’ . “\r\n”;
$more_info_template .= ‘<% if ( phone ) { %>’ . “\r\n”;
$more_info_template .= ‘<span>‘ . esc_html( $wpsl->i18n->get_translation( ‘phone_label’, __( ‘Phone’, ‘wpsl’ ) ) ) . ‘: <%= formatPhoneNumber( phone ) %></span>’ . “\r\n”;
$more_info_template .= ‘<% } %>’ . “\r\n”;
$more_info_template .= ‘<% if ( fax ) { %>’ . “\r\n”;
$more_info_template .= ‘<span>‘ . esc_html( $wpsl->i18n->get_translation( ‘fax_label’, __( ‘Fax’, ‘wpsl’ ) ) ) . ‘: <%= fax %></span>’ . “\r\n”;
$more_info_template .= ‘<% } %>’ . “\r\n”;
$more_info_template .= ‘<% if ( email ) { %>’ . “\r\n”;
$more_info_template .= ‘<span>‘ . esc_html( $wpsl->i18n->get_translation( ’email_label’, __( ‘Email’, ‘wpsl’ ) ) ) . ‘: <%= email %></span>’ . “\r\n”;
$more_info_template .= ‘<% } %>’ . “\r\n”;
$more_info_template .= ‘</p>’ . “\r\n”;// Include data from the custom ‘contato’ field in the info window template.
$more_info_template .= ‘<% if ( contato ) { %>’ . “\r\n”;
$more_info_template .= ‘<span>‘ . esc_html( $wpsl->i18n->get_translation( ’email_label’, __( ‘Contato’, ‘wpsl’ ) ) ) . ‘: <%= contato %></span>’ . “\r\n”;
$more_info_template .= ‘<% } %>’ . “\r\n”;$more_info_template .= ‘</div>’ . “\r\n”;
$more_info_template .= ‘<% } %>’ . “\r\n”;return $more_info_template;
}/* Contato metabox
add_filter( ‘wpsl_meta_box_fields’, ‘custom_meta_box_fields’ );
function custom_meta_box_fields( $meta_fields ) {
$meta_fields[__( ‘Contato’, ‘wpsl’ )] = array(
‘contato’ => array(
‘label’ => __( ‘Contato’, ‘wpsl’ )
)
);return $meta_fields;
}But this view only on admin, on frontend dont see nothing
Sorry my english.
Thanks for help
The topic ‘Custom Additional Information’ is closed to new replies.