Hoi!
Ik zit even met een probleem. Ik heb een script voor een wordpress site. Die zoekt op alles maar hij filtert niet als je in een category zit.
Wat moet ik hier precies in zetten of aanpassen om wel de actuele category te gebruiken als filter? Dus alleen de posts die in de desbetreffende category zitten waar ik op dat moment in zit.
Wie helpt mij ?PHP Code:
function kpg_looser_search_fixup($where) {
if( is_search()===false ) return $where;
global $wpdb;
global $wp_query;
$q=$wp_query->query_vars['s'];
$q=urldecode($q); // ehcoded?
$q=str_replace('_',' ',$q);
$q=str_replace('.',' ',$q);
$q=str_replace('+',' ',$q);
$q=str_replace('"',' ',$q);
$q=str_replace("\'",' ',$q);
$q=str_replace('`',' ',$q);
$q=str_replace(' ',' ',$q);
$q=str_replace(' ',' ',$q);
$q=trim($q);
$qs=explode(' ',$q);
$common=" a able about act add after again air all also am an and animal answer any are as ask at back bad be been before being between big boy build but by call came can case cause change child city close come company could country cover cross day did differ different do does don't down draw each early earth end even every eye fact far farm father feel few find first follow food for form found four from get give go good government great group grow had hand hard has have he head help her here high him his home hot house how i if important in into is it its just keep kind know land large last late learn leave left let life light like line little live long look low made make man many may me mean men might more most mother move mr mrs much must my name near need never new next night no north not now number of off office old on one only or other our out over own page part people person picture place plant play point port press problem public put read real right round run said same saw say school sea see seem self sentence set she should show side small so some sound spell stand start state still story study such sun take tell than that the their them then there these they thing think this thought three through time to too tree try turn two under up upon us use very want was water way we week well went were what when where which while who why will with woman word work world would write year you young your ";
for ($j=0;$j<count($qs);$j++) {
if (strpos($common,' '.$qs[$j].' ')!==false) {
unset($qs[$j]);
}
}
if (count($qs)==0) return $where;
$ptab=$wpdb->posts;
$where= "AND((";
$sql="";
for ($j=0;$j<count($qs);$j++) {
$sss=strtolower(mysql_real_escape_string($qs[$j]));
$sl=strlen($sss);
if ($sl>2) {
$sql.="((LENGTH($ptab.post_content) - LENGTH(REPLACE(LCASE($ptab.post_content), '$sss', '')))/$sl) + ";
$sql.="((LENGTH($ptab.post_title) - LENGTH(REPLACE(LCASE($ptab.post_title), '$sss', '')))*3/$sl) + ";
}
}
$sql.="0";
$where=$where.$sql.")>0) AND $ptab.post_type != 'revision' AND ($ptab.post_status = 'publish' OR $ptab.post_author = 1 AND $ptab.post_status = 'private')";
$wp_query->query_vars['s_kpg']=$sql; // because it's there
return $where;
}
Aanvullend bericht:
o ja, de category id word is al als variable $cat
Aanvullend bericht:
niemand?
- Filteren op category
-
26-06-2011, 23:39 #1
- Berichten
- 95
- Lid sinds
- 15 Jaar
Filteren op category
Laatst aangepast door Daniel S : 27-06-2011 om 11:19 Reden: Automatisch samengevoegd.
-
In de schijnwerper
Plaats een
- + Advertentie
- + Onderwerp
Marktplaats
Webmasterforum
- Websites algemeen
- Sitechecks
- Marketing
- Domeinen algemeen
- Waardebepaling
- CMS
- Wordpress
- Joomla
- Magento
- Google algemeen
- SEO
- Analytics
- Adsense
- Adwords
- HTML / XHTML
- CSS
- Programmeren
- PHP
- Javascript
- JQuery
- MySQL
- Ondernemen algemeen
- Belastingen
- Juridisch
- Grafisch ontwerp
- Hosting Algemeen
- Hardware Info
- Offtopic