Page 1 of 1
ereg_replace in Wordpress
Posted: Thu Oct 22, 2009 4:57 pm
by WithHisStripes
Heya - so I'm working on this site:
http://world-of-smiles.theportlandco.com/new-patients
The site is built off Wordpress and I'm getting the pages title using Wordpress function:
and I'm trying to reformat it's title to all lowercase and replace spaces with dashes. It's working, except that it's adding two dashes to the beginning of the title and I'm not sure why. Can someone help?
Code: Select all
<?php echo ereg_replace(" ", "-", strtolower(wp_title("", false, ""))); ?>
Re: ereg_replace in Wordpress
Posted: Thu Oct 22, 2009 5:19 pm
by markusn00b
WithHisStripes wrote:Heya - so I'm working on this site:
http://world-of-smiles.theportlandco.com/new-patients
The site is built off Wordpress and I'm getting the pages title using Wordpress function:
and I'm trying to reformat it's title to all lowercase and replace spaces with dashes. It's working, except that it's adding two dashes to the beginning of the title and I'm not sure why. Can someone help?
Code: Select all
<?php echo ereg_replace(" ", "-", strtolower(wp_title("", false, ""))); ?>
Warning: ereg_* functions are deprecated as of PHP 5.3 and removed as of PHP 6.
It sounds like your string has leading spaces. Run trim() on the string to remove them.
Code: Select all
ereg_replace(" ", "-", trim(strtolower(wp_title("", false, ""))));
Re: ereg_replace in Wordpress
Posted: Thu Oct 22, 2009 6:17 pm
by WithHisStripes
Awesome, that was it. Yeah I though trim() might do it but I've never used that before today. Thank you!
Re: ereg_replace in Wordpress
Posted: Thu Oct 22, 2009 6:23 pm
by markusn00b
WithHisStripes wrote:Awesome, that was it. Yeah I though trim() might do it but I've never used that before today. Thank you!
No problem
