Проблема Woocommerce с настраиваемой таксономией - PullRequest
0 голосов
/ 29 мая 2020

Я действительно работаю над веб-сайтом магазина, и мне нужно создать новую таксономию для своих брендов.

// hook into the init action and call create_marque_taxonomies when it fires
add_action( 'init', 'create_marque_taxonomies', 0 );

// create marques taxonomy for the post type "product"
function create_marque_taxonomies() {
    // Add new taxonomy, make it hierarchical (like categories)
    $labels = array(
        'name'              => _x( 'Marque', 'taxonomy general name', 'textdomain' ),
        'singular_name'     => _x( 'Marque', 'taxonomy singular name', 'textdomain' ),
        'search_items'      => __( 'Search Marques', 'textdomain' ),
        'all_items'         => __( 'All Marques', 'textdomain' ),
        'parent_item'       => __( 'Parent Marque', 'textdomain' ),
        'parent_item_colon' => __( 'Parent Marque:', 'textdomain' ),
        'edit_item'         => __( 'Editer Marque', 'textdomain' ),
        'update_item'       => __( 'Update Marque', 'textdomain' ),
        'add_new_item'      => __( 'Add New Marque', 'textdomain' ),
        'new_item_name'     => __( 'New Marque Name', 'textdomain' ),
        'menu_name'         => __( 'Marque', 'textdomain' ),
    );

    $args = array(
        'hierarchical'      => true,
        'labels'            => $labels,
        'show_ui'           => true,
        'show_admin_column' => true,
        'query_var'         => true,
        'has_archive'       => true, 
        'rewrite'           => array( 'slug' => 'marques' ),
    );

    register_taxonomy( 'marque', array( 'product' ), $args );
    register_taxonomy_for_object_type( 'marque', 'product' );

}```



Чтобы настроить его, я создаю таксономический бренд. php на сервере, но он не читается.

get_header();


do_action('biagiotti_mikado_action_before_main_content'); ?>

<div id="content-sidebar-wrap">
<?php do_action('genesis_before_content'); ?>

<h2>Je suis la page taxonomy-marque.php</h2>

    <div class="wrap">
        <main class="content"> 
            <?php
                $case_study_cat_slug = get_queried_object()->slug;
                $case_study_cat_name = get_queried_object()->name;
            ?>
                <h2><?php echo $case_study_cat_name; ?></h2>
            <?php
                $al_tax_post_args = array(
                    'post_type' => 'product', // Your Post type Name that You Registered
                    'posts_per_page' => 12,
                    'order' => 'ASC',
                    'tax_query' => array(
                        array(
                            'taxonomy' => 'marque',
                            'field' => 'slug',
                            'terms' => $case_study_cat_slug
                        )
                    )
                );


                $al_tax_post_qry = new WP_Query($al_tax_post_args);

                if($al_tax_post_qry->have_posts()) :
                   while($al_tax_post_qry->have_posts()) :
                        $al_tax_post_qry->the_post();
                        echo '<div class="post-excerpt">'; 
            ?>
                        <h2 class="entry-title" itemprop="headline"><a href="<?php the_permalink(); ?>" class="entry-title-link"><?php  the_title(); ?></a></h2>
                        <div class="entry-content"> <?php echo excerpt(35);  ?> </div>

                        </div>
            <?php
                    endwhile;
                    endif;

            ?>
        </main>         

    </div>  
</div>          

<?php

do_action('genesis_after_content_sidebar_wrap');
get_footer();

Но это не сработало, у меня нет дизайна вроде архив. php. После некоторого поиска я думаю, что проблема связана с плагином woocommerce, особенно с файлом woocommerce. php. О чем вы думаете? Это мой текущий дизайн налога

И это то, что мне нужно (дизайн по умолчанию для кота и тегов

...