为每个产品类别和属性显示一个滑块

时间:2018-06-21 23:48:14

标签: php woocommerce attributes categories shop

我在我的archive-product.php中添加的代码有问题,我想为每个类别和属性添加一个滑块,所以我有以下代码:

此代码在以下类型的页面上有效:https://ferrettistore.com/categoria-producto/cocina/lavaderos/?swoof=1&pa_lavaderos-instalacion=empotrado&really_curr_tax=70-product_cat

但是当我输入以下内容时,会显示一个空格:https://ferrettistore.com/categoria-producto/cocina/lavaderos/

我不知道问题出在哪里,因为此代码是由其他人制作的。我真的很感谢您的帮助。

function show_post($path) {

    $post = get_page_by_path($path);
    if (isset($post->ID)):
        $shortcodes_custom_css = get_post_meta($post->ID, '_wpb_shortcodes_custom_css', true);
        echo '<style type="text/css" data-type="vc_shortcodes-custom-css">';
        echo $shortcodes_custom_css;
        echo '</style>';
        $content = apply_filters('the_content', $post->post_content);
        echo $content;
    endif;
}

if ( is_post_type_archive() ) {

    $term = $wp_query->get_queried_object();
    $cat_id = $_GET['really_curr_tax'];
        $cat_id = str_replace('-product_cat', '', $cat_id);
        if ($term = get_term_by('id', $cat_id, 'product_cat')) {
            $page_title = $term->name;
        }

    show_post('category/'.$term->slug);
}elseif ( is_tax() ) {
    $term = $wp_query->get_queried_object();
    show_post('attribute/'.$term->slug);
}

0 个答案:

没有答案
相关问题