简体   繁体   中英

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. 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. The logic was - if category x is currently displayed use thumbnails of a different size. 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...

Maybe the questions is just broader - How can one work with functions.php and Elementor at the same time?

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.

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 . 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. 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): 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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