hello david,
I'm trying to get one featured product "random" from one category in my widget .
I only want to show one product, selected from 10 different categories. E.g. when I make a category named "sample" and add 10 products (sample\product1, \sample\product2 etc.), the widget must pick one of the featured products from this category.
Is there a way to fix this? I've tried all the other featured products tweaks but didn't manage to get it working...
thanks a lot,
Koen
Hello David,
Thanks... Something goes wrong when implementing this code, I'm getting a:
Parse error: syntax error, unexpected ')' in /home/blablabla/wp-content/plugins/pto/pto_featured.php on line 28 ...
I tried to make line 28 like:
if (isset($section))
but that doesn't make sense (the featured items are not being shown...)...
Any suggestions?
Thanks a lot,
Koen
Sorry Koen,
That line should be
if (isset($parts[1]))
Corrected above...
Cheers,
David.
--
PriceTapestry.com
Hello Koen,
One way to build this in would be to add an optional second parameter to the section (category) value, separated by a colon; e.g. [pto featured="sample:1"] which would return 1 featured product from the sample/ section.
To do this, in pto_featured.php look for the following code beginning at line 25:
if ($section)
{
$sql = "SELECT * FROM `".$pto_config_databaseTablePrefix."featured` WHERE name LIKE '".$wpdb->escape($section)."/%' ORDER BY sequence";
}
...and REPLACE with:
if ($section)
{
$parts = explode(":",$section);
if (isset($parts[1]))
{
$sql = "SELECT * FROM `".$pto_config_databaseTablePrefix."featured` WHERE name LIKE '".$wpdb->escape($parts[0])."/%' ORDER BY RAND() LIMIT ".$parts[1];
}
else
{
$sql = "SELECT * FROM `".$pto_config_databaseTablePrefix."featured` WHERE name LIKE '".$wpdb->escape($section)."/%' ORDER BY sequence";
}
}
Hope this helps!
Cheers,
David.
--
PriceTapestry.com