Forums

[resolved] wp_list_categories breaks only on category pages (3 posts)

  1. eclare
    Member
    Posted 1 year ago #

    Hi there,

    My WP is giving me this error:

    Fatal error: Call to a member function get_queried_object() on a non-object in /home/wydajnykomputer/wydajnykomputer.pl/wp-includes/query.php on line 254

    But it shows ONLY on categories pages:
    http://wydajnykomputer.pl/antywirusy
    and it works fine on other pages:
    http://wydajnykomputer.pl

    The fault code is in rsidebar.php (so it's the same on every page):
    <?php wp_list_categories('show_count=0&title_li=<h2>Artykuły według kategorii</h2>'); ?>
    So it's totally weired that it breaks only on the categorie's pages. Removing this line fixes the error. Removing only the content passed to this function doesn't help.

    I am running these plugins which affect the categories:
    - WP No Category Base
    - All In One SEO Pack
    But turning them off did not solve the problem.

    Also, it seems I'm the only one who has this issue on Google. One guy had a similar error and solved it by writing global $wp_query inside the function stated in the error. For me it already has it global.

    I did not modify the core code. I run 2 more blogs on the same hosting with almost the exact same config and plugins which don't have this error. It does seem like it came up during some plugin or WP updates since I didn't notice it upon setting up WP at the beginning.

    Help please...

  2. eclare
    Member
    Posted 1 year ago #

    I did manage to solve the issue by pasting:

    <?
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query('&paged='.$paged);
    ?>

    on top of archive.php (i noticed it was there in index.php, but not search.php (which works fine), which is weired).

    I have no idea what it does and how it works so if someone could explain, I would be grateful :)
    Also, is the last line needed?

  3. eclare
    Member
    Posted 1 year ago #

    The above did not work for the archives page as I noticed later on. What did help against both problems is typing:
    <? global $wp_query; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic