动态分类术语WordPress

时间:2019-03-11 08:36:06

标签: dynamic taxonomy

我正在将同一页面模板用于多个页面。 -> page-base.php

在使用此模板的每个页面上,我要显示使用CPT创建的类别。

我的问题是,如何使我的数组动态化,以自动更改“分类法”?

这是我的当前代码

<?php  

    $terms = get_terms(
        array(
            'taxonomy'   => 'catmaison',
            'hide_empty' => false,
    ));



if ( ! empty( $terms ) && is_array( $terms ) ) {

    foreach ( $terms as $term ) {

            $the_query = new WP_Query( array( 
            "posts_per_page" => 1,
            "orderby" => 'date', 
            "order" => 'DESC',
            "tax_query" => array(
                array (
                'taxonomy' => 'catmaison',
                'field' => 'term_id',
                'terms' => $term->term_id,
                ),
            ),
            ) );

?>

谢谢

0 个答案:

没有答案
相关问题