Home › Forums › WoodMart support forum › Populare products on top of shop pages
Populare products on top of shop pages
- This topic has 8 replies, 3 voices, and was last updated 5 years, 6 months ago by Artem Temos.
-
AuthorPosts
-
May 12, 2019 at 4:49 pm #123365
metuzaParticipantI have a plugin to display the most popular products on the very top of shop pages but whatever i do editing my code using echo, return, content & ob get clean, priority on action hook and also tested your hooks i am not able to display this loop above categories in archive pages.
I have the same issue with a recently viewed loop loaded using ajax but not able to make it appear below product loop.
This is some of the code i trye to position at top and/or at the very bottom. Works ok if shop page without categories before product loop.
<?php woocommerce_product_loop_start(); ?> <?php while ( $products->have_posts() ) : $products->the_post(); ?> <?php wc_get_template_part( 'content', 'product' ); ?> <?php endwhile; // end of the loop. ?> <?php woocommerce_product_loop_end(); ?>
Any idea?
Brgds
RuneMay 12, 2019 at 9:01 pm #123393
Elise NoromitMemberHello,
Please refer the plugin documentation or contact the plugin support. Our support does not cover plugins. Please note, the shop page is the functional Woocommerce page which should not be edited even with plugins.
Best Regards
May 12, 2019 at 9:37 pm #123398
metuzaParticipantI have build the plugin myself and never had a single issue with any other theme. And we do not edit shop pages or any other page functionality.
Brgds
RuneMay 13, 2019 at 6:06 am #123415
Artem TemosKeymasterHi,
Sorry, but your problem is not quite clear for us. What hook do you use? The code you sent doesn’t have any hooks.
Kind Regards
May 13, 2019 at 7:58 am #123448
metuzaParticipantHello,
Normally i am using “woocommerce_archive_description” and have now tested using “woodmart_before_shop_page” and “woocommerce_before_main_content”. I have tested with the entire range of action priorities and also tested using ajax to load content. No matter what i do the child categories are listed above my loop.
Content like text etc. is positioned without problems so it is only the loop section that is not possible to position before the categories listed on product archive pages.
It loads and is perfectly positioned on any archive page without child categories listed. So it seems like the categories is hooked into the loop as i when loading my loop on top get the categories then my loop, then the categories again and then the main product loop.
I get a similar problem if i want to load my ajax based loop for recently viewed products below the main product loop, then it loads my loop above main product loop and force both loops down to just above footer area.
This problem reminds me about problems seen now and then when a shortcode is loaded without using ob_start – ob_get_clean. Then it sometimes can be impossible to position other content correctly above or below.
Brgds
RuneMay 13, 2019 at 11:13 am #123508
Artem TemosKeymasterHi,
You can check our
woodmart/woocommerce/archive-product.php
and see how it is organized. It has all default WooCommerec hooks so if you have a correct code it should work with our theme as well. There is noob_*
usage there.Kind Regards
May 13, 2019 at 12:02 pm #123520
metuzaParticipantI did find the problem in how you have setup the loop, it seems not possible to hook in between categories and products so i have to setup a separate loop for my populare products.
Brgds
RuneMay 13, 2019 at 12:13 pm #123523
metuzaParticipantI did find a solution. Just removed categories before my loop and added it again after my loop using these filters.
remove_filter( ‘woocommerce_product_loop_start’, ‘woocommerce_maybe_show_product_subcategories’ );
add_filter( ‘woocommerce_product_loop_start’, ‘woocommerce_maybe_show_product_subcategories’ );Works smooth.
Brgds
RuneMay 13, 2019 at 2:30 pm #123545
Artem TemosKeymasterGreat that you found the solution.
-
AuthorPosts
The topic ‘Populare products on top of shop pages’ is closed to new replies.
- You must be logged in to create new topics. Login / Register