简体   繁体   English

为 Elementor 页面使用 functions.php

[英]Using functions.php for Elementor pages

I'm struggling with something specific to elementor I believe.我正在为我相信的元素或特定的东西而苦苦挣扎。 I'm trying to generate a different product grid thumbnail size on one particular category page.我正在尝试在一个特定类别页面上生成不同的产品网格缩略图大小。 The category page is however not the standard woocommerce page but an Elementor template.然而,类别页面不是标准的 woocommerce 页面,而是一个 Elementor 模板。 I've tried a number of PHP/WordPress functions in functions.php but I was not able to check whether I'm on the particular category page or not.我在functions.php 中尝试了许多PHP/WordPress 函数,但我无法检查我是否在特定类别页面上。 The logic was - if category x is currently displayed use thumbnails of a different size.逻辑是 - 如果当前显示类别 x,则使用不同大小的缩略图。 Do you have any ideas how I can achieve this?您对我如何实现这一目标有任何想法吗? I think the usual functions don't work because it is an elementor page.我认为通常的功能不起作用,因为它是一个元素页面。 I couldn't even grab the post id so that I can make an if statement based on it...我什至无法获取帖子 ID,以便我可以根据它做出一个 if 语句......

Maybe the questions is just broader - How can one work with functions.php and Elementor at the same time?也许问题更广泛 - 如何同时使用functions.php和Elementor?

I followed this example I found: https://wordpress.stackexchange.com/questions/131358/how-to-change-the-thumbnail-size-to-a-specific-category but I couldn't get it to work or anything similar.我按照我发现的这个例子: https : //wordpress.stackexchange.com/questions/131358/how-to-change-the-thumbnail-size-to-a-specific-category但我无法让它工作或任何类似的东西。

I believe changing the thumbnail size would not be a problem.我相信更改缩略图大小不会有问题。 The challenge is how to do that only for one particular elementor template.挑战在于如何仅针对一个特定的元素或模板执行此操作。

Because of lazy, i don't install woocommerce in my test site for the guide video here .由于懒惰,我没有在我的测试站点中安装woocommerce以获取此处的指南视频 That why i used posts instead.这就是为什么我用帖子代替。

Your case, my friend.你的情况,我的朋友。 If you install woocommerce, in the elementor pro theme builder will have two tabs for products as image below.如果您安装 woocommerce,则在 elementor pro 主题构建器中将有两个产品标签,如下图所示。 Please use Single Product and Products archive template:请使用单一产品和产品存档模板: 在此处输入图片说明

And to change the grid query from posts to products.并将网格查询从帖子更改为产品。 In the posts setting, query section - change source into products (if you want to only show the products in certain category, then set include by term and select the product category you want to display as below image):在帖子设置,查询部分 - 将来源更改为产品(如果您只想显示某个类别的产品,则设置按术语包含并选择您要显示的产品类别,如下图): 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM