Php 在一些主题WordPress中的category元素下添加子类别很热门

Php 在一些主题WordPress中的category元素下添加子类别很热门,php,wordpress,woocommerce,Php,Wordpress,Woocommerce,我正在尝试建立电子商务网站。遇到类别元素的问题。 我希望元素不仅表示类别,还表示其自身下面的子类别 如果没有UX builder,我也无法编辑页面,我认为这是因为一些主题元素 我想要这样的东西: 类别1类别2 子条款1.1子条款2.1 Subcat1.2_uuuuuuuuuuuuuuSubcat2.2 就像这样: 但是,目前我只能放类别。无法在下面插入子类别。无法更改类别元素 目前使用php脚本在堆栈上尝试了几个示例,但失败了 我请求你的帮助,因为我现在不知道在哪里寻找我需要的信息 在特定的情

我正在尝试建立电子商务网站。遇到类别元素的问题。 我希望元素不仅表示类别,还表示其自身下面的子类别

如果没有UX builder,我也无法编辑页面,我认为这是因为一些主题元素

我想要这样的东西:

类别1类别2

子条款1.1子条款2.1

Subcat1.2_uuuuuuuuuuuuuuSubcat2.2

就像这样:

但是,目前我只能放类别。无法在下面插入子类别。无法更改类别元素

目前使用php脚本在堆栈上尝试了几个示例,但失败了

我请求你的帮助,因为我现在不知道在哪里寻找我需要的信息


在特定的情况下,这可能吗?或者我需要创建整个页面而不使用Flatsome,然后添加自定义元素?

以下是获取父类别和子类别的代码

$parent_cat_arg = array('hide_empty' => false, 'parent' => 0 );
$parent_categories = get_terms('category',$parent_cat_arg);

foreach ($parent_categories as $category) {

    echo '<h2>'.$category->name.'</h2>'; //Parent Category

    $child_arg = array( 'hide_empty' => false, 'parent' => $category->term_id );
    $child_cat = get_terms( 'category', $child_arg );

    echo '<ul>';
        foreach( $child_cat as $child_term ) {
            echo '<li>'.$child_term->name . '</li>'; //Child Category
        }
    echo '</ul>';
$parent\u cat\u arg=array('hide\u empty'=>false,'parent'=>0);
$parent\u categories=get\u terms('category',$parent\u cat\u arg);
foreach($category作为$category的父类){
回显'.$category->name'.';//父类别
$child\u arg=array('hide\u empty'=>false,'parent'=>$category->term\u id);
$child\u cat=get\u术语('category',$child\u arg);
回声“
    ”; foreach($child\u cat作为$child\u术语){ 回显“
  • ”.$child_term->name.
  • ”;//子类别 } 回声“
”;
谢谢!我把你的代码添加到了.PHP中(在子主题中),至少,我在路上。