1
I am giving maintenance on a Wordpress site on which there is a page called "Services" and so there is also the "Service Category", on a certain page of the site, these services are listed within each category.
I am trying to add a new field for "Service Category", the "sort", so that the customer can choose which order will be listed the categories and their services in the format 0 for first, 1 for second and so on.
Well, I saw that a Taxonomy was created for such page but I can not make display the desired additional field. Follow the taxonomy code:
function taxonomiaCategoriaServico() {
$rotulosCategoriaServico = array(
                                    'name'              => 'Categorias de Servico',
                                    'singular_name'     => 'Categoria de Servico',
                                    'search_items'      => 'Buscar categorias de Servico',
                                    'all_items'         => 'Todas categorias de Servico',
                                    'parent_item'       => 'Categoria de Servico pai',
                                    'parent_item_colon' => 'Categoria de Servico pai:',
                                    'edit_item'         => 'Editar categoria de Servico',
                                    'update_item'       => 'Atualizar categoria de Servico',
                                    'add_new_item'      => 'Nova categoria de Servico',
                                    'new_item_name'     => 'Nova categoria',
                                    'menu_name'         => 'Categorias de Servico',
                                );
$argsCategoriaServico       = array(
                                    'hierarchical'      => true,
                                    'labels'            => $rotulosCategoriaServico,
                                    'show_ui'           => true,
                                    'show_admin_column' => true,
                                    'query_var'         => true,
                                    'rewrite'           => array( 'slug' => 'categoria-servico' ),
                                );
register_taxonomy( 'categoriaServico', array( 'servico' ), $argsCategoriaServico );
}
I’ve tried to put everything inside the label, I’ve seen the documentation on Codex on the Wordpress page and also failed.
Follow as I call in the template to show the information.
<?php
                    $conteudoTaxonomias = get_terms( 'categoriaServico', '' );
                    foreach ($conteudoTaxonomias as $conteudoTaxonomia):
                            $foto = $conteudoTaxonomia->description; ?>
                            <div class="col-md-6 serv" style="background: url(<?php echo "$foto"; ?>) no-repeat;">
                                <div class="lente" id="diminuir1">
                                </div>
                                <div class="conteudo">
                                    <h3><i class="fa fa-check-circle" aria-hidden="true"></i> <?php echo $conteudoTaxonomia->name;?></h3>
                                    <ul>
                                        <?php
                                            $servicos = new WP_Query(array(
                                                'post_type'         => 'servico',
                                                'posts_per_page'    => -1,
                                                'tax_query'         => array(
                                                                                array(
                                                                                    'taxonomy' => 'categoriaServico',
                                                                                    'field'    => 'slug',
                                                                                    'terms'    => $conteudoTaxonomia->slug
                                                                                )
                                                                            )
                                                )
                                            );
                                            while ( $servicos->have_posts() ) : $servicos->the_post();
                                        ?>
                                        <li><h3>|   <?php the_title(); ?></h3></li>
                                        <?php endwhile; wp_reset_query(); ?>
                                    </ul>
                                </div>
                            </div>
                    <?php
                    endforeach;
                ?>
Any suggestions?
Dude, I haven’t made it yet. I’m a beginner in wordpress so I kind of hit the head. I edited Edit-tags.php and add the following snippet
<div class="form-field term-order-wrap">
 <label for="tag-order"><?php _e( 'Ordenação' ); ?></label>
 <input name="tag-order" id="tag-order" type="text" value="" size="40" aria-required="true" />
</div>and already showed the field. And at the beginning of the archive is the$ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST );but information is not saving– Bruno Folle
opa, opa, take 2 steps back. You ** cannot ** edit the
edit-tags.phpunder no circumstances. Otherwise when Wordpress is updated you will lose everything. These changes have to go in your theme or plugin.– Ricardo Moraleida
In fact, not only Edit-tags: never edit ANYTHING outside the folder
wp-content– Ricardo Moraleida
I understand, I will try to edit the plugin, so I understood the taxonomy was declared in the plugin in a file that has the same name of the project/ site
– Bruno Folle
One question, the $this object what would be? The plugin where taxonomy is declared has no public and private objects and functions
– Bruno Folle
$this is when it is in a class. If it is only a procedural file you can exchange the array for a string with the function name.
– Ricardo Moraleida
I was able to make the field appear like that in the plugin, but I can’t save the value of the field. The function that saves also goes in the plugin?
– Bruno Folle