且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用Shopify和Liquid在我的主页上显示所有产品?

更新时间:2023-10-25 16:52:04

大多数主题在其主页上显示一个集合.使用该功能,不要添加代码.

Most themes display a collection on their home page. Go with that functionality, don't add code.

要使您的主页集合包含商店中的所有产品,请使其成为具有条件(例如产品价格> 0)的智能集合.

For your home page collection to include all products in your store, make it a smart collection with a condition such as Product Price > 0.

如果您的商店中有50多种产品,则可以通过在模板/index.liquid文件中添加Liquid标签来向您的主页添加分页.为了获得有关如何在Shopify主题中进行分页的灵感,请查看您的template/collection.liquid文件.

If you have more than 50 products in your shop, you can add pagination to your home page by adding Liquid tags to your templates/index.liquid file. For inspiration on how pagination is done in a Shopify theme, look into your templates/collection.liquid file.

您的主题可能会对您的主页上显示的主页集合中的多少产品有一定的限制.在这种情况下,您可以在templates/index.liquid文件中找到类似以下代码的代码:

There is possibly some limit imposed by your theme on how many products from your homepage collection are shown on your home page. If that's the case, you'll find code that looks like this in your templates/index.liquid file:

{% for product in collections.frontpage.products limit: 12 %}

删除限制属性.