如何将wooccommerce侧边栏移动到商店商品上方,使其位于移动设备的顶部


How do I move the woocommerce sidebar to be above the shop items so that it is at the top at mobile?

我有一个网站,Wooccommerce商店页面将类别放在左边。当您将大小调整为移动设备时,类别会向下弹出到页面底部。我希望它能出现在顶部。我想用php来做这件事,而不是做一堆javascript更改或css规则。

好的,所以我找到的解决方案是进入主题的文件夹,然后进入config-woocommerce文件夹。在config.php文件的函数avia_woocommerce_after_main_content()中,有以下代码:

        //get the sidebar
        if(!is_singular())
        get_sidebar();

我从该函数中删除了该代码,并将其移到以下代码后面的函数avia_woocommerce_before_man_content中:

$sidebar_setting = avia_layout_class( 'main' , false );
echo "<div class='container_wrap container_wrap_first main_color {$sidebar_setting} template-shop shop_columns_".$avia_config['shop_overview_column']."'>";
    echo "<div class='container'>";

现在函数看起来是这样的:

function avia_woocommerce_before_main_content()

{全局$avia_config;

if(!isset($avia_config['shop_overview_column'])) $avia_config['shop_overview_column'] = "auto";
$id = get_option('woocommerce_shop_page_id');
$layout = get_post_meta($id, 'layout', true);
if(!empty($layout))
{
        $avia_config['layout']['current'] = $avia_config['layout'][$layout];
        $avia_config['layout']['current']['main'] = $layout;
}
    $avia_config['layout'] = apply_filters('avia_layout_filter', $avia_config['layout'], $id);
$title_args = array();
if(is_woocommerce())
{
    $t_link = "";
    if(is_shop()) $title  = get_option('woocommerce_shop_page_title');
    $shop_id = woocommerce_get_page_id('shop');
    if($shop_id && $shop_id != -1)
    {
        if(empty($title)) $title = get_the_title($shop_id);
        $t_link = get_permalink($shop_id);
    }
    if(empty($title)) $title  = __("Shop",'avia_framework');
    if(is_product_category() || is_product_tag())
    {
        global $wp_query;
        $tax = $wp_query->get_queried_object();
        $title = $tax->name;
        $t_link = '';
    }
    $title_args = array('title' => $title, 'link' => $t_link);
}
if( get_post_meta(get_the_ID(), 'header', true) != 'no') echo avia_title($title_args);

if(is_singular()) { 
    $result = 'sidebar_right';
    $avia_config['layout']['current'] = $avia_config['layout'][$result];
    $avia_config['layout']['current']['main'] = $result;
}
$sidebar_setting = avia_layout_class( 'main' , false );
echo "<div class='container_wrap container_wrap_first main_color {$sidebar_setting} template-shop shop_columns_".$avia_config['shop_overview_column']."'>";
    echo "<div class='container'>";
    //get the sidebar
    if(!is_singular())
        get_sidebar();
    if(!is_singular()) { $avia_config['overview'] = true; }

}

这适用于enfold主题,我想这将适用于每个主题。我必须处理css,才能让它得到它,这样页面看起来就对了,但这是它的css部分。