Home

Public Domain Photos

Free for commercial redistribution and alteration (All photo from http://publicphoto.org/ is 100% free for use)

WordPress Slug Function – for Permalink

wordpress logoUntrusted data comes from imputs it needs to be validated both on input and output. WordPress transforms title to a permalink usig output sanitation function.

Slugs function:

sanitize_title( $title )

Specifically, HTML and PHP tags are stripped.

Usage

<?php sanitize_title( $title, $default_title ) ?>

Parameters

$title (string) (required) The string to be sanitized. Default: None

$default_title (string) (optional) A title to use if $title is empty. Default: ”

Examples Sanitize Titles

<?php
$slug
_url = sanitize_title('WordPress Slug Function – for Permalink');
echo $slug
_url;
?>

the output will be:

wordpress-slug-function—for-permalink

[ Short URL ... ]

Leave a Reply

 

Powered by WordPress ::