Forums

[resolved] unable to call $wpdb on wp-login.php (4 posts)

  1. haxxxton
    Member
    Posted 2 years ago #

    Hey guys,

    I am having an issue on my current development site. I am using a shopping cart plugin that pulls the wp-login.php file as an include.. this allows users to log in to the site while maintaining the header navigation, footer and sidebars etc.

    the issue im running into is that i am using $wpdb class to create my customised navigation.. using this call every page seems to work great, other than the wp-login.php page.

    The error i get says

    Notice: Undefined variable: wpdb in /wp-content/themes/shopperpress/header.php on line 230
    
    Fatal error: Call to a member function get_col() on a non-object in /wp-content/themes/shopperpress/header.php on line 230

    line 230 starts

    $nav_item = $wpdb->get_col("SELECT post_title FROM <code>wp_posts</code> WHERE post_type='page' AND post_status ='publish' AND post_parent =0");

    is there an action hook i can implement in the functions.php that will allow me to keep my $wpdb call even on the wp-login.php page?

    Thanks so much

    James

  2. Rahul Sonar
    Member
    Posted 2 years ago #

    if it is a function where you are using this object, you need to use global $wpdb

  3. haxxxton
    Member
    Posted 2 years ago #

    argh OF COURSE

    silly me assumed it loads the global $wpdb call early in the function calls already..

    thanks Rahul :)

  4. 123milliseconds
    Member
    Posted 2 years ago #

    Please mark thread as resolved so that

    - others with similar problem can see it as resolved and will read this thread for help if they have similar problem

    - people providing help see it as resolved and will not waste time reading this post.

Topic Closed

This topic has been closed to new replies.

About this Topic