0
我有一个网站,Woocommerce商店页面将类别放在左侧。当您调整到移动设备时,类别会弹出到页面的底部。我希望它出现在顶部。我想用php做到这一点,而不是做一堆javascript更改或css规则。如何将woocommerce侧边栏移动到商店项目的上方以便移动设备位于顶部?
我有一个网站,Woocommerce商店页面将类别放在左侧。当您调整到移动设备时,类别会弹出到页面的底部。我希望它出现在顶部。我想用php做到这一点,而不是做一堆javascript更改或css规则。如何将woocommerce侧边栏移动到商店项目的上方以便移动设备位于顶部?
好的,我找到的解决方案是进入主题的文件夹,然后进入config-woocommerce文件夹。在config.php文件,功能avia_woocommerce_after_main_content()有下面的代码:
//get the sidebar
if(!is_singular())
get_sidebar();
我删除代码从功能和下面的代码后马上移动到功能avia_woocommerce_before_main_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; }
}
这曾与包裹的主题,我假定这将与每一个主题的工作。我不得不惹上CSS来获取它,以便页面看起来正确,但这是它的CSS部分。