• Resolved whatsupskip

    (@whatsupskip)


    I am not sure what caused this error to start appearing on my pages. On some pages it only shows twice and others it shows four or five times. The full message is:
    Notice: Trying to get property of non-object in /public_html/dev/wordpress/wp-includes/link-template.php on line 323

    Notice: Trying to get property of non-object in /public_html/dev/wordpress/wp-includes/link-template.php on line 337

    From my searching I found that a similar error message occurs when a site is hacked and the link-template.php file name is changed.

    The sections of code correspond to the following code:

    /**
     * Retrieve the permalink for current page or page ID.
     *
     * Respects page_on_front. Use this one.
    
    *
     * @since 1.5.0
     *
     * @param int|object $post      Optional. Post ID or object.
     * @param bool       $leavename Optional, defaults to false. Whether to keep page name.
     * @param bool       $sample    Optional, defaults to false. Is it a sample permalink.
     * @return string The page permalink.
     */
    function get_page_link( $post = false, $leavename = false, $sample = false ) {
    	global $wp;
    	$post = get_post( $post );
    
    	if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) )
    		$link = home_url('/');
    	else
    		$link = _get_page_link( $post, $leavename, $sample );
    
    	/**
    	 * Filter the permalink for a page.
    	 *
    	 * @since 1.5.0
    	 *
    	 * @param string $link    The page's permalink.
    	 * @param int    $post_id The ID of the page.
    	 * @param bool   $sample  Is it a sample permalink.
    	 */
    	return apply_filters( 'page_link', $link, $post->ID, $sample );
    }

    Any help would be appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    A hacked site could cause any number of errors. Any specific error cannot necessarily be attributed to hacking, there’s many other non-malicious causes that generate the same error.

    In this case calling get_page_link() with an invalid page ID will cause the same Notice. This will happen when called from within a non-standard loop where $GLOBALS['post'] is not set. This can happen on page templates that run extra queries. You’ll need to look at the call stack to locate where the erroneous call came from.

    Thread Starter whatsupskip

    (@whatsupskip)

    Thanks for the help.

    I tried a few different things, but in the end it appears that deactivating and activating the related plugin worked.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Trying to get property of non-object in link-template.php’ is closed to new replies.