Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have this line …

<div class="permalink"><?php the_permalink(); ?></div>

and the result on my page looks like this …

http://mysite.com/whatever/post-or-so

I guess it could also look like this …

http://www.mysite.com/whatever/post-or-so

However I'd like to have just mysite.com/whatever/post-or-so without the http:// or www in front of it.

What is the best and easiest way to do so?

Don't get me wrong, this has nothing todo with rewriting permalinks or whatsoever. Just a simple echo of the_permalink() on my page that is not handled as link but as normal text. And in this case I would like to get rid of the http or www.

share|improve this question

2 Answers

up vote 0 down vote accepted

use get_permalink instead of the_permalink and manipulate it however you'd like via php.

share|improve this answer
<?php
    $find = 'http://';
    $replace = '';
    echo '<p>' . str_replace($find,$replace,get_permalink()) . '</p>';
?>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.