Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/245.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 用于自定义分类的Woocommerce产品归档页面_Php_Wordpress_Woocommerce_Custom Taxonomy - Fatal编程技术网

Php 用于自定义分类的Woocommerce产品归档页面

Php 用于自定义分类的Woocommerce产品归档页面,php,wordpress,woocommerce,custom-taxonomy,Php,Wordpress,Woocommerce,Custom Taxonomy,我为WooCommerce产品注册了自定义分类法。此外,我还设置了一个页面模板,用分类法归档链接列出自定义分类法的所有条目。现在我有一个问题,归档链接不起作用。我希望它们的工作方式类似于产品类别和产品标签归档页面。我是否需要设置自定义归档页面文件,或者代码中是否缺少某些内容?感谢您的任何提示或帮助提前 // Register Custom Taxonomy function ffos_custom_taxonomy_Brand() { $labels = array( 'name'

我为WooCommerce产品注册了自定义分类法。此外,我还设置了一个页面模板,用分类法归档链接列出自定义分类法的所有条目。现在我有一个问题,归档链接不起作用。我希望它们的工作方式类似于产品类别和产品标签归档页面。我是否需要设置自定义归档页面文件,或者代码中是否缺少某些内容?感谢您的任何提示或帮助提前

// Register Custom Taxonomy
function ffos_custom_taxonomy_Brand()  {

$labels = array(
    'name'                       => 'Brands',
    'singular_name'              => 'Brand',
    'menu_name'                  => 'Brands',
    'all_brands'                  => 'All Brands',
    'parent_item'                => 'Parent Brand',
    'parent_item_colon'          => 'Parent Brand:',
    'new_item_name'              => 'New Brand Name',
    'add_new_item'               => 'Add New Brand',
    'edit_item'                  => 'Edit Brand',
    'update_item'                => 'Update Brand',
    'separate_items_with_commas' => 'Separate Brand with commas',
    'search_items'               => 'Search Brands',
    'add_or_remove_items'        => 'Add or remove Brands',
    'choose_from_most_used'      => 'Choose from the most used Brands',
);
$args = array(
    'labels'                     => $labels,
    'hierarchical'               => true,
    'public'                     => true,
    'show_ui'                    => true,
    'show_admin_column'          => true,
    'show_in_nav_menus'          => true,
);
register_taxonomy( 'product_brand', 'product', $args );

}

add_action( 'init', 'ffos_custom_taxonomy_Brand', 0 );
$args=array(
'orderby'=>'name',
“订单”=>ASC,
“hide_empty”=>true,
);
$product\U brand=获取术语('product\U brand',$args);
if($product\U brand&!is\U wp\U error($product\U brand)){
foreach($product\U brand作为$brand){
$brand_logo=获取_字段('brand_logo',$brand);
$brand_title=$brand->name;
$brand\u link=获取术语链接($brand);
回声';
回声';
回声';
}
}

在WP admin中,转到设置>永久链接并单击按钮“保存更改”。重写规则必须刷新。现在它就像一个符咒

天哪,你让我开心!已经找了好几个小时不知道怎么了最后。。。谢谢
$args = array(
  'orderby'    => 'name',
  'order'      => ASC,
  'hide_empty' => true,
);

$product_brand = get_terms( 'product_brand', $args );

if ( $product_brand && ! is_wp_error( $product_brand ) ) {

  foreach ($product_brand as $brand) {

    $brand_logo = get_field('brand_logo', $brand);
    $brand_title = $brand->name;
    $brand_link = get_term_link( $brand );

    echo '<div class="small-12 medium-4 large-2 columns" >';
    echo '<a href="'.$brand_link.'">';
    echo '<div class="brand_logo" style="background-image:url('.$brand_logo.');" alt="'.$brand_title.'"></div>';
    echo '</a>';
    echo '</div>';
  }
}