Title: Problem with get_page_by_path function
Last modified: August 31, 2016

---

# Problem with get_page_by_path function

 *  [nicomoka](https://wordpress.org/support/users/nicomoka/)
 * (@nicomoka)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/problem-with-get_page_by_path-function/)
 * Hi,
    I’am using this plugin to translate the slugs. I have a problem when i want
   to get the page (post) corresponding to a path, using the wp function “get_page_by_path”.
   I have a url like this [http://www.example.com/english-slug/shop](http://www.example.com/english-slug/shop)
   and the url [http://www.example.com/swede-slug/shop](http://www.example.com/swede-slug/shop).
   I have defined a rules that specified the correct page to go when in the url 
   appears the word “shop”. When i go to this page i have to get the post corresponding
   to “english-slug” or “swede-slug”, and this post have to be the same obviously.
   I use the function like this: $post = get_page_by_path(‘english-slug’,OBJECT,’
   post’); but dont found the page. This is a bug in the plugin? Or how can i get
   the post using the translated slug? without make a query in database of course.
   Thanks!!!
 * [https://wordpress.org/plugins/qtranslate-slug/](https://wordpress.org/plugins/qtranslate-slug/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Pedro Carvalho](https://wordpress.org/support/users/pedroghandi/)
 * (@pedroghandi)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/problem-with-get_page_by_path-function/#post-7023345)
 * Hi nicomoka,
    I didn’t quite understood what you are trying to do.
 * when are you filtering the url?
 * do you have access to the id? if so, you can get the correct url by using:
 *     ```
       $the_slug_in_lang = qts_get_slug( $id, $lang );
       ```
   
 * if not, QTS has a private version of `get_page_by_path`,
 * for example, i did this:
 *     ```
       global $qtranslate_slug;
       $this_post = $qtranslate_slug->get_page_by_path(basename( untrailingslashit( qts_get_url() )));
       $this_id = $this_post->ID;
       var_dump($this_id);
       ```
   
 * To do that, i had to change the function `get_page_by_path` signature to public.
   its in file inc/class-qtranslate-slug.php, line 1225.
 * I might create a public function to do that, if there’s a need for that, so you
   don’t have to keep changing the function.

Viewing 1 replies (of 1 total)

The topic ‘Problem with get_page_by_path function’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/qtranslate-slug_5fb35e.svg)
 * [Qtranslate Slug](https://wordpress.org/plugins/qtranslate-slug/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/qtranslate-slug/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/qtranslate-slug/)
 * [Active Topics](https://wordpress.org/support/plugin/qtranslate-slug/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/qtranslate-slug/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/qtranslate-slug/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Pedro Carvalho](https://wordpress.org/support/users/pedroghandi/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/problem-with-get_page_by_path-function/#post-7023345)
 * Status: not resolved