Michael Harmon
Michael Harmon

Reputation: 43

WordPress Permalink <?php the_permalink(); ?>

I am trying to grab a permalink for a page in WordPress and am using the following:

<?php the_permalink(); ?>

It works fine, but I need to strip something out of the output. It returns the following:

http://www.testing.com/es/patients/

Which is correct, but I want to strip out the "/es"

Is there a command I can add to this to strip out the /es and have it just say:

http://www.testing.com/patients/

Upvotes: 0

Views: 379

Answers (1)

Marcin
Marcin

Reputation: 1494

You need to include those PHP lines on your page:

<?php
   $url = the_permalink();
   $final_url = str_replace("/es", "", $url);
   echo $final_url;
?>

Then you can work in that edited variable $final_url

Upvotes: 1

Related Questions