I’m trying to create a function that returns a slug from a title that comes from an array of data id the way of
@foreach($pests as $p)
<a href="/services/pests-we-control/#{{$p['name-desc']['name']}}" class="text-center pests-carousel-item">
@endforeach
the problem i’m facing is the name came with spaces in between so i need to make use of sanitize_title in order to convert the spaces in dashes. tried several things, nothing seemed to work, when i tried to pass the data to the controller, im getting
[25-Mar-2018 14:19:08 UTC] PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function App\FrontPage::getUrl(), 0 passed in ..../vendor/soberwp/controller/src/Controller.php on line 105 and exactly 1 expected in ..../app/controllers/front-page.php:23
<?php
namespace App;
use Sober\Controller\Controller;
class FrontPage extends Controller
{
public function getUrl($title){ <=== is not being passed to the controller
return sanitize_title('$title');
}
}
what i’m doing wrong?