Skip to main content

Reply To: How to exclude certain category id from listing in latest ad?

ClassiBase classifieds script Forums General help How to exclude certain category id from listing in latest ad? Reply To: How to exclude certain category id from listing in latest ad?

#1112 Reply

Elite Tan
Participant

I tried to add to below but not working can you please guide me is the categoery_id code correct or should be category or id or category_id, and the “where” need to add the dot “.”? please advice where to add below under the Ad.php to exclude category id 166, Thanks alot and to hear from you again……..
———
public static function latestAds($num = 20, $location = null, $category = null)
{

$cache_key = ‘ad.latest.l’ . intval($location->id) . ‘.c’ . intval($category->id) . ‘.’ . intval($num);
$ads = SimpleCache::get($cache_key);
if($ads === false)
{
$whereA = array(‘ad.listed=?’);
$whereB = array(1);

Ad::buildLocationQuery($location, $whereA, $whereB);
Ad::buildCategoryQuery($category, $whereA, $whereB);

$where .= ‘ AND category_id!=166’;
$where = str_replace(‘ad.’, ”, implode(‘ AND ‘, $whereA));

$ads = Ad::findAllFrom(‘Ad’, $where . ‘ ORDER BY published_at DESC LIMIT ‘ . $num, $whereB);

SimpleCache::set($cache_key, $ads);
}
return $ads;
}

  • Classifieds Business Newsletter

    Get discounts and tips about growing your classifieds website.

    Subscribe