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):
Related
I would like to modify the behavior of upsells and cross-sells product search in the admin product edit. It should search only in product titles.
By default, it searches description as well. That’s why there are too many score, I can’t find the product what I search.
[1
I had the same problem with the frontend product finder, but I solved it with a hook. Is there any hook for upsell and cross-sell finder?
Thanks!
The search request goes to this function
https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php#L1582
There you can find a filter woocommerce_product_pre_search_products for a custom result, so basically you'll have to copy-paste the whole code below that filter line and remove a few things from line no 1651 or you can just modify the core plugin files.
However, I don't see any specific param to identify the request so this change will affect everywhere on the website where search_products is used from the data store.
I am importing products via Product Import Export for WooCommerce by WebToffee, I then have a function that pulls data from an API and populates the data in each imported product.
Everything works perfectly, except Yoast breadcrumbs don't show properly when I view the product. The breadcrumbs on the frontend will say e.g.
Shop » Product Name instead of the full category and sub-category breadcrumb trail.
The only way I can successfully get the breadcrumbs to show properly is by manually editing the product and clicking update, it then shows correctly, as in:
Shop » Workwear » High Visibility » Hi Vis Polo Shirts & T-Shirts » Product Name
This would be fine, except I will be importing thousands of products in one sitting so I need a programmatic solution to add to my function which will make the breadcrumbs display properly on the frontend.
What I've tried so far
In my function I've tried populating the following custom metadata within each product:
_yoast_wpseo_metadesc
_yoast_wpseo_title
_yoast_wpseo_primary_product_cat
_yoast_wpseo_content_score
_yoast_wpseo_estimated-reading-time-minutes
But unfortunately setting all of the above doesn't seem to affect the display of the breadcrumbs.
I've also tried clearing product transients in wp-admin after import and product creation but this didn't resolve the issue.
Any ideas on how I can get this working? Is there a function I can run as part of the WC-Product object which will trigger the breadcrumbs to sort themselves out as it does when manually clicking Update in edit product?
Any help would be greatly appreciated
Well it really depends how you're importing products. Currently, when each product insert, SEO Yoast meta isn't setting up in database so everytime you need to edit and update that product.
The custom meta might also not worked in your case because you're not inserting data in other Yoast table like _yoast_indexable.
Can you show us how you're importing products so we might help you?
Just in case it helps anyone else in the future having the same issue, the problem was due to my code, which modified the category and Yoast primary category after the last execution of wp_update_post.
Simply running wp_update_post( $product_id ) after programmatically updating the category / primary category fixed the malformed breadcrumb issue.
I created a WooCommerce category, added description and an image to it.
There are some products in the category too.
Looking at the category in frontend (/product-category/mycat/) I see category description and product images - but not a category image. I tested it with all default WP themes and with Storefront too - category image is in no theme visible.
In the rendered source code there is nothing similar to category image - after title and description comes immediately the sorting dropdown:
What I'm missing?
Shouldn't category image appear automatically on the category page?
Or should I nevertheless trigger its displaying with adding of any code to theme file?
Indeed, the solution from https://stackoverflow.com/a/12717177/1992004 is working for me - the category image appears.
Is there really no solution without custom code?
"Shouldn't category image appear automatically on the category page? Or should I nevertheless trigger its displaying with adding of any code to theme file?"
Short answer
No it does not show up by default! It all depends on the template/theme developer's architecture/preferences and how s/he has planned the theme out! If you'd like to customize your theme, then you could go ahead and add it manually to your theme templates using the snippet you found!
I have a WooCommerce store with Elementor.
I'm using an Elementor category product page template to generate the product page for each set of products.
I want to use this plug-in to create a table instead of a product grid: https://barn2.co.uk/wordpress-plugins/woocommerce-product-table/
To display the table, the creator of the plug-in provides the following shortcode: [Product Table]. I know you can modify the table to display a specific sub-category, but is it possible to automatically pull the subcategory for each page from a single shortcode? If not, I would need to create a new template for each shortcode...
For example: If I fill in the product id of e.g. category 2 in the shortcode, the Elementor product page template will display the table for this category on every page.
Question
Can I make the subcategory aspect of a shortcode dynamic? Preferably, the X is set automatically to the product's category of which page is being visited.
There is a question very similar to this, but I am a beginner and the .php code they provided was a little hard to understand...
Here's a link to the original question: Insert WooCommerce product id dynamically in shortcode
Any help would be greatly appreciated! Thanks guys.
It looks like this page in the plugin documentation answers your question.
I am facing a weird problem and it has consumed all my time. I am working on a plugin based on woocommerce. For this I have added code snippet from this solution for loading woocommerce templates from my plugin folder and I am successfull in same.
The problem is when I have multiple products in same product category I can see that all the product pages are displaying same tab content like description and comments (product reviews). This happens only when I have a comment posted for any of the products.
I noticed that tabs.php on woocommerce templates is loading only one product id irrespective of what product it should display. Can anyone help me solving this?
UPDATE 1
My understanding was wrong that this issue ocurring only when products are in same category. Instead this issue is showing up when the products post author is same for the noticed products.