Crocoblock / suggestions

The suggestions for CrocoBlock project
196 stars 79 forks source link

CCT Singel Page #7782

Closed deniro83 closed 3 hours ago

deniro83 commented 1 month ago

adding Single Page to CCT

function generate_slug($title) {
// Convert to lowercase
$title = mb_strtolower($title, 'UTF-8');
// Converting Polish characters to Latin
$title = str_replace(
['ą','ć','ę','ł','ń','ó','ś','ź','ż','Ą','Ć','Ę','Ł','Ń','Ó','Ś','Ź','Ż'],
['a','c','e','l','n','o','s','z','z','A','C','E','L','N','O','S','Z','Z'],
$title
);
// Removing special characters
$title = preg_replace('/[^a-z0-9\s-]/', '', $title); // Replacing spaces with dashes
$title = preg_replace('/[\s-]+/', '-', $title);
// Removing double dashes
$title = trim($title, '-');
return $title;
}

Based on this field, a link would be generated (like in CPT), but it would be saved in the database as one of the rows, e.g.

this_is_my_product

and together it would look like this

http://mypage.com/products/this_is_my_product

this would open the way to other benefits.