How to get full slug, including all parent pages

I am trying for hours and I managed to get full slug for parent of sub-page when I am on 3rd level sub-page I can not get slug of the top parent page. Example
domain.com/top_page/sub_page/sub_sub_page

I need to get full slug ‘top_page/sub_page/sub_sub_page’

I am doing this for language sites that are on sub-domains (individuals sites). These pages have same slug across sub-domains. So I want to link language site that when you are on some given page link to language site will take you to that page in that language (not home page of that language).

example of hyperlink to English language sub-domain:

echo '<a href="https://wordpress.stackexchange.com/questions/47378/en.domain.com/".get_FULL_SLUG).'">'English'</a>';

Is it possible to get slug of top parent when you are on third level page, sub-sub-page

Hope somebody can help

2 Answers
2

This would replace domain.com/top_page/sub_page/sub_sub_page with /top_page/sub_page/sub_sub_page

$path = str_replace(home_url(),'',get_permalink());

Leave a Comment