• Hi, I’m using $wpdb in my theme files, (a custom Thematic child theme), and everything is working fine, BUT if i modify a template file (header-extensions.php) located in the PARENT theme directory, i can’t seem to connect to the database.

    code that works fine in a php file located in my CHILD theme folder works, such as

    global $wpdb;
    $lightboxes = $wpdb->get_results( "SELECT * FROM wp_usermeta WHERE meta_key = 'lightbox' AND user_id = $user_ID");
    <select>
    <option>--Select from your lightboxes--</option>
        <?php
    
    	foreach ($lightboxes as $lightbox) {
    		if ($lightbox->meta_value != $editLB) {
    			echo '<option>'.$lightbox->meta_value.'</option>';
    		}
    	}
    
    	?></select>

    but, the following code, while it seems to connect to the database, returns no results

    <?php
    						global $wpdb;
    
    						if ($user_ID) {
    							$getLightboxes = $wpdb->get_results( "SELECT * FROM wp_usermeta WHERE meta_key = 'lightbox' AND user_id = $user_ID");
    						}
    
    						if (!$getLightboxes) {
    							echo '<li><a href="http://therapytest.com/wordpress/?page_id=40">You have no lightboxes</a></li>';
    
    						} else {
    							foreach ($getLightboxes as $lightbox) {
    								echo '<li><a href="">'.$lightbox->meta_value.'</a>
    								<ul><li><a href="">view</a></li></ul>
    								</li>';
    							}
    						}
    						 ?>

    is there any reason why i am unable to connect to the database and/or return results from the files located in a PARENT theme folder?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘problem with $wpdb’ is closed to new replies.