MB Frontend Submission to taxonomies
Support › MB Frontend Submission › MB Frontend Submission to taxonomiesResolved
- This topic has 3 replies, 2 voices, and was last updated 4 years ago by
Long Nguyen.
-
AuthorPosts
-
April 16, 2021 at 1:27 AM #27288
Alexandre Siqueira siqale
ParticipantI a newbie in WordPress and Metabox, but I'm learning fast. The Meta Box plugin is very good.
I created a new taxonomy and your custom fields, and after create the custom fields I did put the shortcode in a page to create a new taxonomy in front-end. When I open the page I received a message:<br> "Notice: Trying to get property 'base' of non-object in /var/www/html/wp-content/plugins/meta-box-aio/vendor/meta-box/mb-term-meta/src/MetaBox.php on line 77"
Is this possible, or there aren't suport to this funcionality? If the suport exist, what do I doing wrong.
Thanks very much for help.
April 16, 2021 at 10:39 AM #27303Long Nguyen
ModeratorHi Alexandre,
Thank you for reaching out.
Can you please share the code that creates the meta box, custom fields, and the shortcode to show the form on the front end? Some screenshots would be appreciated.
April 17, 2021 at 5:31 AM #27328Alexandre Siqueira siqale
ParticipantOk Mr Long, let's go to the information
Agencia - Taxonomy code
<?php add_action( 'init', 'your_prefix_register_taxonomy' ); function your_prefix_register_taxonomy() { $labels = [ 'name' => esc_html__( 'Agências', 'your-textdomain' ), 'singular_name' => esc_html__( 'Agência', 'your-textdomain' ), 'menu_name' => esc_html__( 'Agências', 'your-textdomain' ), 'search_items' => esc_html__( 'Search Agências', 'your-textdomain' ), 'popular_items' => esc_html__( 'Popular Agências', 'your-textdomain' ), 'all_items' => esc_html__( 'All Agências', 'your-textdomain' ), 'parent_item' => esc_html__( 'Parent Agência', 'your-textdomain' ), 'parent_item_colon' => esc_html__( 'Parent Agência', 'your-textdomain' ), 'edit_item' => esc_html__( 'Edit Agência', 'your-textdomain' ), 'view_item' => esc_html__( 'View Agência', 'your-textdomain' ), 'update_item' => esc_html__( 'Update Agência', 'your-textdomain' ), 'add_new_item' => esc_html__( 'Add new agência', 'your-textdomain' ), 'new_item_name' => esc_html__( 'New agência name', 'your-textdomain' ), 'separate_items_with_commas' => esc_html__( 'Separate agências with commas', 'your-textdomain' ), 'add_or_remove_items' => esc_html__( 'Add or remove agências', 'your-textdomain' ), 'choose_from_most_used' => esc_html__( 'Choose most used agências', 'your-textdomain' ), 'not_found' => esc_html__( 'No agências found', 'your-textdomain' ), 'no_terms' => esc_html__( 'No agências found', 'your-textdomain' ), 'items_list_navigation' => esc_html__( 'Agências list pagination', 'your-textdomain' ), 'items_list' => esc_html__( 'Agências list', 'your-textdomain' ), 'most_used' => esc_html__( 'Most Used', 'your-textdomain' ), 'back_to_items' => esc_html__( 'Back to agências', 'your-textdomain' ), 'text_domain' => esc_html__( 'your-textdomain', 'your-textdomain' ), ]; $args = [ 'label' => esc_html__( 'Agências', 'your-textdomain' ), 'labels' => $labels, 'description' => 'Cadastro de Agências Sisunic', 'public' => true, 'publicly_queryable' => true, 'hierarchical' => false, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'meta_box_cb' => true, 'show_in_rest' => false, 'show_tagcloud' => true, 'show_in_quick_edit' => true, 'show_admin_column' => true, 'query_var' => true, 'sort' => false, 'rest_base' => '', 'rewrite' => [ 'with_front' => false, 'hierarchical' => false, ], ]; register_taxonomy( 'agencia', ['cliente', 'is_search_form'], $args ); }
Aditionals Agencia customized fields
<?php add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' ); function your_prefix_function_name( $meta_boxes ) { $prefix = ''; $meta_boxes[] = [ 'title' => __( 'Campos Adicionais Agência', 'your-text-domain' ), 'id' => 'campos-adicionais-agencia', 'taxonomies' => ['agencia'], 'fields' => [ [ 'name' => __( 'Nome Fantasia', 'your-text-domain' ), 'id' => $prefix . 'nome_fantasia', 'type' => 'text', 'columns' => 4, ], [ 'name' => __( 'CNPJ', 'your-text-domain' ), 'id' => $prefix . 'cnpj', 'type' => 'text', 'columns' => 4, ], [ 'name' => __( 'CRC', 'your-text-domain' ), 'id' => $prefix . 'crc', 'type' => 'text', 'columns' => 4, ], [ 'name' => __( 'Contador', 'your-text-domain' ), 'id' => $prefix . 'contador', 'type' => 'text', 'columns' => 6, ], [ 'name' => __( 'CEP', 'your-text-domain' ), 'id' => $prefix . 'cep', 'type' => 'text', 'columns' => 4, ], [ 'name' => __( 'Logradouro', 'your-text-domain' ), 'id' => $prefix . 'rua', 'type' => 'text', 'columns' => 6, ], [ 'name' => __( 'Complemento', 'your-text-domain' ), 'id' => $prefix . 'complemento', 'type' => 'text', 'columns' => 4, ], [ 'name' => __( 'Bairro', 'your-text-domain' ), 'id' => $prefix . 'bairro', 'type' => 'text', 'columns' => 4, ], [ 'name' => __( 'Cidade', 'your-text-domain' ), 'id' => $prefix . 'cidade', 'type' => 'text', 'columns' => 4, ], [ 'name' => __( 'UF', 'your-text-domain' ), 'id' => $prefix . 'uf', 'type' => 'text', 'columns' => 3, ], [ 'name' => __( 'Email', 'your-text-domain' ), 'id' => $prefix . 'email', 'type' => 'email', 'columns' => 4, ], [ 'name' => __( 'Telefone', 'your-text-domain' ), 'id' => $prefix . 'telefone', 'type' => 'text', 'columns' => 4, ], [ 'name' => __( 'Celular', 'your-text-domain' ), 'id' => $prefix . 'celular', 'type' => 'text', 'columns' => 4, ], [ 'name' => __( 'Dados adicionais', 'your-text-domain' ), 'id' => $prefix . 'dados_adicionais', 'type' => 'textarea', 'columns' => 4, ], [ 'name' => __( 'Mapa', 'your-text-domain' ), 'id' => $prefix . 'mapa', 'type' => 'osm', 'address_field' => 'logradouro, bairro, cidade, uf, cep', 'language' => 'pt-BR', 'region' => 'br', 'columns' => 6, ], [ 'name' => __( 'Logo', 'your-text-domain' ), 'id' => $prefix . 'logo', 'type' => 'single_image', 'columns' => 6, ], ], ]; return $meta_boxes; }
Shortcode
[mb_frontend_form id='campos-adicionais-agencia' post_fields='title']
No images available (i'm using just in localhost)
Error message on page where shortcode was inserted
Notice: Trying to get property 'base' of non-object in /var/www/html/wp-content/plugins/meta-box-aio/vendor/meta-box/mb-term-meta/src/MetaBox.php on line 77
April 18, 2021 at 10:37 AM #27343Long Nguyen
ModeratorHi,
Currently, we have not supported creating a new term with term meta on the frontend. If you want to create a new term when creating a new post, please use the field type
taxonomy
ortaxonomy_advanced
, setting'add_new' => true
Get more details on this documentation
https://docs.metabox.io/fields/taxonomy/#settings
https://docs.metabox.io/fields/taxonomy-advanced/#settings -
AuthorPosts
- You must be logged in to reply to this topic.