Trying to use str_replace to remove a directory from the_permalink() in Wordpress:
$the_old_link = the_permalink();
$the_new_link = str_replace('/unwanted_folder', '', $the_old_link);
Instead of the_permalink()
, you have to use get_permalink()
if you want to store a value in PHP. the_permalink()
is meant for displaying output, not for setting variables.
See the following: http://codex.wordpress.org/Function_Reference/get_permalink http://codex.wordpress.org/Function_Reference/get_permalink