Is it possible to select against a post’s parent’s fields with WP_Query?

You should use posts_join and posts_where filters to modify JOIN and WHERE clauses. add_filter( ‘posts_join’ , ‘se333659_posts_join’, 20, 2 ); add_filter( ‘posts_where’ , ‘se333659_posts_where’, 20, 2 ); function se333659_posts_join( $join, $query ) { global $wpdb; if ( isset($query->query_vars[‘_rev_of_publ’]) && $query->query_vars[‘_rev_of_publ’] == ‘1’ ) { $join .= ” LEFT JOIN {$wpdb->posts} AS rev_p ON ({$wpdb->posts}.post_parent = … Read more

Get the exact SQL query that get_posts() generated

The get_posts() function creates an instance of WP_Query inside the function and simply returns the array of results. This WP_Query instance doesn’t override the global $wp_query and is out of scope by the time you need it. In short, I don’t see a way how you can get the requested SQL via get_posts(). An alternative … Read more

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) { … } }

Sharing database for collaborative development

Yes. Use WP_HOME and WP_SITEURL in your wp-config.php, so the URLs in the database won’t mess (a lot) with local site development. define (‘WP_HOME’, ‘http://local/site/url’); define (‘WP_SITEURL’, ‘http://local/site/url’); Also, some other good practices: Put in your .gitignore things like: wp-config.php wp-content/uploads wp-content/cache wp-content … # Everything that is created by users .htaccess Make a copy … Read more

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