dpzbh1779 2016-01-06 19:35
浏览 49
已采纳

如何将woocommerce侧边栏移动到商店商品上方,以便它在移动设备上位于顶部?

I have a site that the Woocommerce shop page places the categories on the left. When you resized down to mobile, the categories would pop down to the bottom of the page. I wanted it to show up at the top. I wanted to do this with php, instead of making a bunch of javascript changes or css rules.

  • 写回答

1条回答 默认 最新

  • doulei1965 2016-01-06 19:35
    关注

    Ok so the solution that I found was to go into the theme's folder, and then into config-woocommerce folder. In the config.php file, the function avia_woocommerce_after_main_content() there is the following code:

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

    I removed that code from that function and moved it to the function avia_woocommerce_before_main_content right after the following code:

    $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'>";
    

    So now the function looks like this:

    function avia_woocommerce_before_main_content()
    

    { global $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; }
    

    }

    This worked with the enfold theme, I'm assuming that this will work with every theme. I do have to mess with the css in order to get it to get it so that the page looks right but this is the css portion of it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图