Display data from a non wordpress database on a page template

As Ben suggested, you need to pass the connection details when creating the wpdb class: $newdb = new wpdb( ‘user’, ‘password’, ‘database’, ‘hostname’ ); You should also test that the query actually returned something before using the result in a foreach loop: if ($rows) { foreach ($rows as $obj) { … } }

Get terms that contain posts that in turn belong to other terms?

This should get you the names of all such terms in an array $wpdb->get_col(“SELECT DISTINCT {$wpdb->terms}.name FROM {$wpdb->terms} INNER JOIN {$wpdb->term_taxonomy} ON {$wpdb->term_taxonomy}.term_id = {$wpdb->terms}.term_id INNER JOIN {$wpdb->term_relationships} ON {$wpdb->term_taxonomy}.term_taxonomy_id = {$wpdb->term_relationships}.term_taxonomy_id WHERE {$wpdb->term_taxonomy}.taxonomy = ‘shape’ AND {$wpdb->term_relationships}.object_id IN ( SELECT object_id FROM {$wpdb->term_relationships} INNER JOIN {$wpdb->term_taxonomy} ON {$wpdb->term_taxonomy}.term_taxonomy_id = {$wpdb->term_relationships}.term_taxonomy_id WHERE {$wpdb->term_taxonomy}.taxonomy = ‘color’ … Read more

Hook into $wpdb

query – you will get sql as argument of the callback. add_filter(‘query’, ‘some_callback_that_change_query’); function some_callback_that_change_query($sql){ remove_filter(‘query’, ‘some_callback_that_change_query’); // your banny wrote add_filter(‘query’, ‘some_callback_that_change_query’); return $sql; }

Inserting data into custom tables

You said your form is in the main folder? I guess you need to set proper URL for action=””. You could try: action=”<?php echo site_url() . ‘/setLiquorType.php’; ?>” It is best practice to put your form code into functions.php and then leave form action=”” empty. Then you can trigger your form function when the form … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)