Andres
Andres

Reputation: 2023

wordpress get current permalink or url without domain

I'm not sure if I titled this correctly but this is my issue, I have to create 2 same exact blogs and the only difference is language. So but what I need is at the top when clicked on a language it would take the user to that same page but in the language he/she clicked on.

I'm using permalinks currently and I've tried the following:

<?php 
   function my_permalink() {
    echo substr(get_permalink(), strlen(get_option('home')));
   }

   my_permalink();
?>

but that for some reason on my home page points to a post and not the home page. I believe that works in posts but I need that to also work on the home. Here's the links to both blogs, any help is much appreciated..

English: http://www.inblu.pe/prblog/ Spanish: http://www.inblu.pe/prbloges/

Upvotes: 1

Views: 7184

Answers (2)

Justin
Justin

Reputation: 31

How about the_permalink? I'm fighting with that now.

~ Justin

Upvotes: 0

Alexandre Lavoie
Alexandre Lavoie

Reputation: 8771

It could be more simple with standard PHP method :

$_SERVER["REQUEST_URI"]

Of course it will work for current post only.

You can also use that :

<?php 
   function my_permalink() {
    echo substr(get_permalink(), strlen(home_url('/')));
   }

   my_permalink();
?>

Upvotes: 2

Related Questions