最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

customization - Taxonomy template is not reading

programmeradmin1浏览0评论

I've created a woocommerce shop by using biagiotti theme and I add a taxonomy with the follow code :


// create marques taxonomy for the post type "product"
function create_marque_taxonomies() {
    // Add new taxonomy, make it hierarchical (like categories)
    $labels = array(
        'name'              => _x( 'Marques', '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'         => __( 'Edit 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,
        'rewrite'           => array( 'slug' => 'marque' ),
    );

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

}

After that in my child-theme, I've created a taxonomy-marque.php file to custom template with this code :

get_header();


do_action('genesis_before_content_sidebar_wrap'); ?>

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

    <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();

but it don't work and my taxonomy page still have no design like archive.php

How can I do ? Please help I'm desesperate

发布评论

评论列表(0)

  1. 暂无评论