Ответы пользователя по тегу WooСommerce
  • Как сделать динамический запрос в WP_Query?

    Ну по сути - здесь можно сделать шорткод

    И расточить шорткод для ваших целей - где вы будете задавать тип записи, кол-во постов, таксономию и т.д - можно вообще все

    // Shortcode for projects [projects-list posts="3"]
    function projects_listing_parameters_shortcode( $atts ) {
        ob_start();
    
        $args = shortcode_atts( array (
            'type' => 'projects',
            'posts' => 6,
            'cat' => ''
        ), $atts );
    
        $options = array(
            'post_type' => $args['type'],
            'posts_per_page' => $args['posts'],
            'tax_query' => array(
                array (
                    'taxonomy' => 'project',
                    'field' => 'slug',
                    'terms' => $args['cat'],
                )
            ),
        );
    
        $query = new WP_Query( $options );
    
        if ( $query->have_posts() ) $item = 0; {
            while ( $query->have_posts() ) : $query->the_post(); $item++;
                echo '<div class="item item-' . $item . '">';
                    get_template_part( 'template-parts/project-cards', get_post_format() );
                echo '</div>';
            endwhile;
            wp_reset_postdata();
            $myvariable = ob_get_clean();
            return $myvariable;
        }
    }
    add_shortcode( 'projects-list', 'projects_listing_parameters_shortcode' );
    Ответ написан
    Комментировать
  • Как сделать чтобы фильтр не закрывался?

    Здравствуйте!

    У вас все ведет в этот файл:
    https://evro-brend.ru/wp-content/themes/woodmart/js/functions.min.js


    В этом файле есть функция отвечающаяя за этот сайдбар - hideShopSidebar - там все настройки и хранятся..в том числе и закрытие сайдбара после клика

    В этом месте вызывается эта функция:
    (woodmartThemeModule.ajaxFilters = function () {
                if (a("body").hasClass("woodmart-ajax-shop-on") && void 0 !== a.fn.pjax && !a("body").hasClass("single-product")) {
                    var c = this,
                        d = !1;
                    a(".products");
                    a("body").on("click", ".post-type-archive-product .products-footer .woocommerce-pagination a", function (a) {
                        e(!0);
                    }),
                        a(document).pjax(b.ajaxLinks, ".main-page-wrapper", { timeout: woodmart_settings.pjax_timeout, scrollTo: !1 }),
                        "click" == woodmart_settings.price_filter_action
                            ? a(document).on("click", ".widget_price_filter form .button", function () {
                                  var b = a(".widget_price_filter form");
                                  return a.pjax({ container: ".main-page-wrapper", timeout: woodmart_settings.pjax_timeout, url: b.attr("action"), data: b.serialize(), scrollTo: !1 }), !1;
                              })
                            : "submit" == woodmart_settings.price_filter_action &&
                              a(document).on("submit", ".widget_price_filter form", function (b) {
                                  var c = a(".main-page-wrapper");
                                  a.pjax.submit(b, c);
                              }),
                        a(document).on("pjax:error", function (a, b, c, d) {
                            console.log("pjax error " + c);
                        }),
                        a(document).on("pjax:start", function (b, c) {
                            a(".site-content").removeClass("ajax-loaded"), a(".site-content").addClass("ajax-loading"), woodmartThemeModule.hideShopSidebar();
                        }),
                        a(document).on("pjax:complete", function (b, d, f) {
                            c.shopPageInit(),
                                e(!1),
                                a(document).trigger("wood-images-loaded"),
                                a(".woodmart-sidebar-content").scroll(function () {
                                    a(document).trigger("wood-images-loaded");
                                }),
                                a(".site-content").removeClass("ajax-loading");
                        }),
                        a(document).on("pjax:beforeReplace", function (b, c) {
                            a(".filters-area").hasClass("filters-opened") && "yes" == woodmart_settings.shop_filters_close && ((d = !0), a("body").addClass("body-filters-opened"));
                        }),
                        a(document).on("pjax:end", function (b, c, e) {
                            d && (a(".filters-area").css("display", "block"), woodmartThemeModule.openFilters(200), (d = !1)), a(".site-content").removeClass("ajax-loading"), a(".site-content").addClass("ajax-loaded");
                        });
                    var e = function (b) {
                        if ("no" == woodmart_settings.ajax_scroll && 0 == b) return !1;
                        var c = a(woodmart_settings.ajax_scroll_class),
                            d = c.offset().top - woodmart_settings.ajax_scroll_offset;
                        a("html, body").stop().animate({ scrollTop: d }, 400);
                    };
                }
            }),


    А конкретнее - здесь:
    a(document).on("pjax:start", function (b, c) {
                            a(".site-content").removeClass("ajax-loaded"), a(".site-content").addClass("ajax-loading"), woodmartThemeModule.hideShopSidebar();
                        }),


    Возможно, стоит попробовать вот так:
    a(document).on("pjax:start", function (b, c) {
                            a(".site-content").removeClass("ajax-loaded"), a(".site-content").addClass("ajax-loading");
                        }),


    Но это не точно...нужно пробовать
    Ответ написан
    1 комментарий