WordPress.org

Ready to get started?Download WordPress

Forums

Pages Posts
[SOLVED] Fatal error: Call to a member function get_queried_object() (8 posts)

  1. Gengar003
    Member
    Posted 1 year ago #

    If Pages Posts gives you the following error at the bottom of your blog:

    Fatal error: Call to a member function get_queried_object() on a non-object in /....../wp-includes/admin-bar.php on line 440

    and breaks the admin bar when you're logged in, this is the solution:

    In "functions.php," insert the following line on line 238:

    $wp_query = $GLOBALS['wp_query'];

    There should be THREE closing braces } before that line, and TWO closing braces } after the line.

    The goal is to have it after the switch() statement that starts on line 138.

    After making this change, the admin bar will work, and the error will go away.

    This fix is needed as of Pages-posts version 2.1. Hopefully it will be fixed in future releases.

    http://wordpress.org/extend/plugins/pages-posts/

  2. iMake
    Member
    Posted 1 year ago #

    Hello

    I am just trying to sort this out as I have having this error message.

    I am new to editing PHP so would really appreciate some help :-)

    So far I have gone in to the plugin via the plugins page of my site and gone to 'edit'. I have selected functions.php and gone in to edit. But I cannot seem to position the extra bit ($wp_query = $GLOBALS['wp_query'];) in the right place. I cannot find it. I have counted the lines to line 238 but still putting the text there doesn't seem to work.

    Any help would really be appreciated.

    Thank you

    Martine

  3. tombyrnes
    Member
    Posted 1 year ago #

    Gengar03

    Brilliant, just brilliant. Followed your detailed advice and it worked like a charm. (BTWE: It wasn't exactly at line 238, for me at least, but just above - with the braces count it was a doddle.

    Thanks a squillion. You are my hero.

    Cheers

    Tom

  4. pvdw
    Member
    Posted 1 year ago #

    Hi Gengar003 and tombyrnes!

    I see you have were able to fix the problem.
    Thought I'm having some problems with placing the:
    $wp_query = $GLOBALS['wp_query']; (within the functions.php)

    Can't really find the three }'s and the two {'s either..

    Anyone able to help me out, would be really appreciated!

  5. tombyrnes
    Member
    Posted 1 year ago #

    Attention pvdw:

    For me the change was around line 228. Look for the following lines:
    ----------------------------------------------------------
    if($showAsHome)
    {
    // Flag as a home page
    $GLOBALS['wp_query']->is_home = true;
    $GLOBALS['wp_query']->is_archive = false;
    $GLOBALS['wp_query']->is_category = false;
    }
    }
    }
    ----------------------------------------------------------------
    NB There will only be one such group of "wp_query" references that is followed by THREE closing braces. After those three closing braces AND before the next TWO closing braces, insert the line:
    $wp_query = $GLOBALS['wp_query'];
    -----------------------------------------------------------------
    so you should end up with something like:
    ----------------------------------------------------------------
    if($showAsHome)
    {
    // Flag as a home page
    $GLOBALS['wp_query']->is_home = true;
    $GLOBALS['wp_query']->is_archive = false;
    $GLOBALS['wp_query']->is_category = false;
    }
    }
    }
    $wp_query = $GLOBALS['wp_query'];
    }
    }

    if(!function_exists('pagesPostsAdmin'))
    ---------------------------------------------------------------------
    if you still don't get it, post another message with your email address suitably masked (eg "at" for "@" "dot" for "." kinda thing.
    Good luck.

  6. pvdw
    Member
    Posted 1 year ago #

    I'm very much getting the feeling that my functions.php is totally different from yours.

    Maybe it's indeed beter to handle this via email.
    If you'd be so kind to email me at: needatisprive at gmail dot com

    Thanks in advance!

  7. tombyrnes
    Member
    Posted 1 year ago #

    Hi pvdw

    Detailed email sent to the address you provided.
    Let me know if you get it OK.

  8. pvdw
    Member
    Posted 1 year ago #

    Hi Tombyrnes,

    I received your email and you totally solved my problem!.

    My problem was looking at the incorrect functions.php (I looked at the Twenty Eleven theme functions.php)

    For others who are having the same problem and can't figure it out.
    The file you should be modifying is located at:
    "root/wp-content/plugins/pages-posts/functions.php"

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic