jasoncarlmorgan
Forum Replies Created
-
Problem solved, now working perfectly.
This is how i did it!.$values = array( (int) $_POST["city"], (int) $_POST["route"], (int) $_POST["vehicle"], ); if($values[0] == 0) $values[0]=''; if($values[1] == 0) $values[1]=''; if($values[2] == 0) $values[2]=''; $values = array_filter($values); $values = array_values($values); query_posts(array('category__and' => $values)); endif ?>
What a relief this is. The best part of two days working on this.
Many thanks to all who contributed!Yup, i just proven that statement above by swapping the order in which the array values are created and long behold, the 1st array value displays. The others are being ignored.
I’ve got a feeling i know what its doing but unsure how to sort it out:
query_posts(array('category__and' => $filter)); //where $filter is an array
i think its ONLY displaying posts from the 1st array value and ignoring the other two.
further update:
this works how category__and should:
query_posts(array('category__and' => array(1042,1192,1055)));
but this work like category__in NOT how it should:
query_posts(array('category__and' => $filter)); //where $filter is an array.
i must be missing something.
Ok, so i applied the fix as stated above in changeset/11501
and im currently using the following method:
$filter = array(); if($city != 0) $filter[] = $city; if($route != 0) $filter[] = $route; if($vehicle != 0) $filter[] = $vehicle; if(count($filter > 0)) { $filter = array(implode(',',$filter)); query_posts(array('category__and' => $filter)); }
basically from what i can tell, the fix HAS worked to some degree.
… BUT,category__and now definatley works, however its basically acting like category__in!! – not like category__and is suppose to.
Am I right in saying this is the fix?
I’m on the latest 2.8 beta, is this why?
Ok, another finding! This ones a bombshell!
$filter = array(); if($city != 0) $filter[] = $city; if($route != 0) $filter[] = $route; if($vehicle != 0) $filter[] = $vehicle; if(count($filter > 0)) { $filter = array(implode(',',$filter)); query_posts(array('category__in' => $filter)); }
The above WORKS! – YES WORKS.
Therefor, using category__in works but, using category__and doesnt?
…go figure.However it still doesnt sort my problem as i HAVE to be able to use category__and
OK – Nevermind, it turns out that has nothing to do with this problem!
Ok! – update:
I added the following to the start of the script:
error_reporting(E_ALL);
This is what resulted:
Notice: Use of undefined constant city – assumed ‘city’ in /home/wyiana1/public_html/leaguespy.com/pgr/wp-content/themes/connections/catfilter.php on line 4
Notice: Use of undefined constant route – assumed ‘route’ in /home/wyiana1/public_html/leaguespy.com/pgr/wp-content/themes/connections/catfilter.php on line 5
Notice: Use of undefined constant vehicle – assumed ‘vehicle’ in /home/wyiana1/public_html/leaguespy.com/pgr/wp-content/themes/connections/catfilter.php on line 6
strange how this works:
query_posts('cat=' . $example); // where $example holds the Cat ID's.
and how this doesnt:
query_posts(array('category__and' => $example)); // where $example holds the Cat ID's.
query_posts(array('category__and' => array(1042,1192,1055)));
does’nt work!!! – havent tried that next bit, is there point?
t31os_ – cheers for the thought, tried as suggested but returns No Posts! – just like all the others! Sorry mate, worth a try though, thanks.
Hello guys, back from evening out. Meal was lovely!
Anyhow, Otto42 here’s the output from what you’ve asked.
array(3) { [0]=> int(1042) [1]=> int(1192) [2]=> int(1055) }
That is the result. My category ID’s are very high – this is normal.
Many Thanks
I’m out at the Chinese restaurant! – Will let you know later when I get home!
Cheers for the help!