piotrpepson
Forum Replies Created
-
Thanks @afzalpansuvi
Its work ?? One other question, I have noticed that the code look not only in product title, but in product description as well. Any suggestion how to modify below code that will only search in product tiles excluding description
function custom_dynamic_category_query($query) {
// Check if we are on the product category page and target a specific category
if (is_product_category(‘Prostownice do w?osów’) && $query->is_main_query()) {
// Specific word in the product title IMPORTANT: this part do not works exactly, beside the title the product description is taken. How to limit only to product title ??
$query->set(‘s’, ‘prostownica’);
}
}
add_action(‘pre_get_posts’, ‘custom_dynamic_category_query’);I have corrected the code with help of ChatGPT, now its work fine:
if (is_product_category(‘Prostownice do w?osów’)
was changed with:
if (is_product_category(‘Prostownice do w?osów’) && $query->is_main_query()) {
whole code:
function custom_dynamic_category_query($query) {
// Check if we are on the product category page and target a specific category
if (is_product_category(‘Prostownice do w?osów’) && $query->is_main_query()) {
// Specific word in the product title
$query->set(‘s’, ‘prostownica’);
}
}
add_action(‘pre_get_posts’, ‘custom_dynamic_category_query’);One remarks, codes work fine but there is one small issue.
After clicking in the category the menu star to display not he store category but some random page names see: screen shots.
- go to the address: https://trycho-medica.pl/sklep/
- click in the category: “Prostownice do w?osów”: https://trycho-medica.pl/kategoria-produktu/wszystkie-produkty/prostownice-do-wlosow/
any thoughts ?
code used:
function custom_dynamic_category_query($query) {
// check if the category is the one that need to be dynamically filtered
if (is_product_category(‘category_name’)) {
// Specific word in the product title
$query->set(‘s’, ‘word_in_product_title’);
}
}
add_action(‘pre_get_posts’, ‘custom_dynamic_category_query’);Hi All,
I have found solution, its so easy. If your category is fulfilled by integrator and products are imported from external source, then if you want to have dynamic “smart” categories like in Shopify.
- Download the Snipes app for adding the code to function.php
- Rename you category that contains all products, example: “Shampoo for hair grow”
- Past below code to the Snipes app (create new code):
function custom_dynamic_category_query($query) {
// Sprawd?, czy jeste?my na stronie kategorii, dla której ma dzia?a? funkcja
if (is_product_category(‘twoja_wybrana_kategoria’)) {
// Dodaj warunek dla wyszukiwania s?owa w tytule produktu
$query->set(‘s’, ‘s?owo_do_wyszukania_w_tytule’);
}
}
add_action(‘pre_get_posts’, ‘custom_dynamic_category_query’);4. in the code -> change the name of the twoja_wybrana_kategoria’ to ‘Shampoo for hair grow’
5. in the code -> change the word that is in the poduct title ‘s?owo_do_wyszukania_w_tytule’ to ‘Shampoo for hair grow’
Activate the code, your ‘Shampoo for hair grow’ category will only shows product that have in title: “‘Shampoo for hair grow”
No need for hire developer, do it by your self ??
probably some dev work need to be done, I need to have categories that shows products based on the title filter , anyone can refer some good dev to implement that solution ?
Hi, Thank you or reply, this solution will not work, i have already implemented API import interface from Syncee.
Another idea that I have in my mind is the filtering option, directly on the category page. Is there any way to code or set up permanent filter (not visible for visitors) after clicking in the menu, client will see only the products that will contain in title special works
please let me know
but I need few categories that will contain specific products that contains specific product titles.
I have integration turned on, dynamically new products are added in the daily basis, and categories need to be smart, need to display product based on the criteria.
All the products contain specific product type name in the title, base on that category need to have criteria to be setup
category: shampoo
criteria: product title contain “shampoo”
Etc.
Hi @carolm29
here you have the link to payment settings: https://zapodaj.net/plik-13iYfXJYsE
and the status report: https://megawrzuta.pl/download/e9a6a1d2e481c780d87019e25909597d.html
Forum: Installing WordPress
In reply to: After domain configuration page start to display wrongThank you @gappiah , I will try to follow your advice
Forum: Installing WordPress
In reply to: After domain configuration page start to display wronghi @gappiah , it was changed in both configuration, two fields and one fields, and it make the same effect, page display with missing elements