You are here:  » Problem with WP filters

Active Forum Topics


Problem with WP filters

Submitted by ccgale on Thu, 2018-06-28 07:55 in

Hi

Wondering if I could have a quick bit of help, please. I am using the tool with WordPress. I followed the various guides to adding additional, scan and set, product filters. However, when I add the following to my pto.php file, the filters show up on the front end, along with the relevant options but selecting them just refreshes the page title and doesn't alter products

global $pto_filters;
$pto_filters = array("colour","style","shape","features","material","occasion");
foreach($pto_filters as $pto_filter)
{
array_push($vars, 'pto_".$pto_filter."Filter');
}

An example can be seen at {link saved} - although the PT is very heavily customised, the problem happens even with the basic set up so I don't feel the theme changes are the cause.

Any advice would be most welcome, please

Thank you

Submitted by support on Thu, 2018-06-28 09:30

Hi,

The initial modification to pto.php looks fine, and then filter HTML appears to be working correctly, so just to confirm the additional changes required in pto_search.php for plugin version 3;

Look for the following code at line 108:

  $parts = explode(":",$pto_q);

...and REPLACE with:

  global $pto_filters;
  foreach($pto_filters as $pto_filter)
  {
    $fn = "pto_".$pto_filter."Filter";
    $$fn = $_GET[$fn];
    if ($$fn) $priceWhere .= " AND ".$pto_filter." = '".esc_sql($$fn)."' ";
  }
  $parts = explode(":",$pto_q);

And then the following code at line 479:

  $sortBaseHREF .= "&pto_sort=";

...and REPLACE with:

  global $pto_filters;
  foreach($pto_filters as $pto_filter)
  {
    $vn = "pto_".$pto_filter."Filter";
    $$vn = (isset($_GET[$vn])?$_GET[$vn]:"");
    if ($$vn) $sortBaseHREF .= "&".$vn."=".urlencode($$vn);
  }
  $sortBaseHREF .= "&pto_sort=";

And finally the following code at line 717:

      $navigationBaseHREF .= "&pto_page=";

...and REPLACE with:

      global $pto_filters;
      foreach($pto_filters as $pto_filter)
      {
        $vn = "pto_".$pto_filter."Filter";
        $$vn = (isset($_GET[$vn])?$_GET[$vn]:"");
        if ($$vn) $navigationBaseHREF .= "&".$vn."=".urlencode($$vn);
      }
      $navigationBaseHREF .= "&pto_page=";

If that's all in place but still no joy if you could email me your modified pto.php and pto_search.php I'll check it out further with you...

Cheers,
David.
--
PriceTapestry.com

Submitted by ccgale on Fri, 2018-06-29 09:34

Working perfectly now, thank you