• I’m customising a theme to match my needs for my website (looking back I realise I should have most definitely used a child theme, but I stupidly did not).

    I’m extremely new to coding wordpress, however have some experience with coding in the past… So may need some detailed explanation (SORRY!)

    I’m getting these 3 errors repeat 5 times on my home page:

    • Notice: Trying to get property of non-object in /Applications/MAMP/htdocs/wordpress/wp-includes/query.php on line 4520
    • Notice: Trying to get property of non-object in /Applications/MAMP/htdocs/wordpress/wp-includes/query.php on line 4522
    • Notice: Trying to get property of non-object in /Applications/MAMP/htdocs/wordpress/wp-includes/query.php on line 4524

    I’ve just changed the home page to a static home page and the errors began to appear, they do not show up on any other page.

    [moderated to add missing ul]

Viewing 1 replies (of 1 total)
  • So query.php is the main script which implements the API for query WordPress. The line numbers above point to the is_page function which checks to see if the current page that WordPress is rendering is a single page, as opposed to an index/archive page.

    The page_object in this function is not getting set, which is causing your problem. The page object is set from the get_queried_object function.

    The reason why this is not returning anything suggests you are calling a WP API function at the wrong point in the code execution, or at an unexpected place in you custom theme.

    Take a look at https://wordpress.stackexchange.com/questions/128685/get-queried-object-returns-null-on-post-date-archive for some ideas of where the problem might be.

    Another approach would be to debug the code in the query.php. This code will not be wrong but it will give you an idea of what parameters are being passed through to the function and why this might be causing the errors you are seeing, and allow you to trace what is happening.

Viewing 1 replies (of 1 total)
  • The topic ‘PHP: Property of non-object – Query Ln 4520-24’ is closed to new replies.