Title: Patch for fixing a notice
Last modified: August 22, 2016

---

# Patch for fixing a notice

 *  [KLicheR](https://wordpress.org/support/users/klicher/)
 * (@klicher)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/patch-for-fixing-a-notice/)
 * polylang-1.6.5
 * I got a notice when I tried to use the function `pll_the_languages(array('raw'
   => true))` within the hook `wp`: `Notice: Undefined property: WP_Query::$queried_object_id
   in /.../wp-includes/query.php on line 3960`.
 * I patched the file _frontend/frontend-links.php_ to use the `get_queried_object_id`
   function instead of directly trying to access the property like this: `$wp_query-
   >queried_object_id`.
 * **The patch**
 *     ```
       diff --git a/frontend/frontend-links.php b/frontend/frontend-links.php
       index f5c7e78..89f3b40 100644
       --- a/frontend/frontend-links.php
       +++ b/frontend/frontend-links.php
       @@ -231,17 +231,18 @@ class PLL_Frontend_Links extends PLL_Links {
                       global $wp_query;
                       $qv = $wp_query->query_vars;
                       $hide = $this->options['default_lang'] == $language->slug && $this->options['hide_default'];
       +               $queried_object_id = $wp_query->get_queried_object_id();
   
                       // post and attachment
       -               if (is_single() && ($this->options['media_support'] || !is_attachment()) && ($id = $this->model->get_post($wp_query->queried_object_id, $language)) && $this->current_user_can_read($id))
       +               if (is_single() && ($this->options['media_support'] || !is_attachment()) && ($id = $this->model->get_post($queried_object_id, $language)) && $this->current_user_can_read($id))
                               $url = get_permalink($id);
   
                       // page for posts
                       // FIXME the last test should be useless now since I test is_posts_page
       -               elseif ($wp_query->is_posts_page && !empty($wp_query->queried_object_id) && ($id = $this->model->get_post($wp_query->queried_object_id, $language)) && $id == $this->model->get_post($this->page_for_posts, $language))
       +               elseif ($wp_query->is_posts_page && !empty($queried_object_id) && ($id = $this->model->get_post($queried_object_id, $language)) && $id == $this->model->get_post($this->page_for_posts, $language))
                               $url = get_permalink($id);
   
       -               elseif (is_page() && ($id = $this->model->get_post($wp_query->queried_object_id, $language)) && $this->current_user_can_read($id))
       +               elseif (is_page() && ($id = $this->model->get_post($queried_object_id, $language)) && $this->current_user_can_read($id))
                               $url = $hide && $id == $this->model->get_post($this->page_on_front, $language) ? $this->links_model->home : get_page_link($id);
   
                       elseif (!is_tax('post_format') && !is_tax('language') && (is_category() || is_tag() || is_tax()) ) {
       ```
   
 * Thanks
 * [https://wordpress.org/plugins/polylang/](https://wordpress.org/plugins/polylang/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/patch-for-fixing-a-notice/#post-5810111)
 * Hi!
 * Thank you for your suggestion. I will update the code.
    EDIT: Could you tell 
   me on what kind of page you get the error?

Viewing 1 replies (of 1 total)

The topic ‘Patch for fixing a notice’ is closed to new replies.

 * ![](https://ps.w.org/polylang/assets/icon-256x256.png?rev=3433336)
 * [Polylang](https://wordpress.org/plugins/polylang/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/polylang/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/polylang/)
 * [Active Topics](https://wordpress.org/support/plugin/polylang/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/polylang/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/polylang/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Chouby](https://wordpress.org/support/users/chouby/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/patch-for-fixing-a-notice/#post-5810111)
 * Status: not resolved