pixite
1
Hi,
Is it possible to do a custom query loop with $wpdb?
I am hoping to use the below code in the query and use meta fields to populate the content.
global $wpdb;
$table_name = $wpdb->prefix . 'wpsr_reviews';
$results = $wpdb->get_results( "SELECT reviewer_name, reviewer_url, reviewer_text, review_time, rating FROM $table_name WHERE reviewer_text IS NOT NULL AND rating = 5" );
foreach ($results as $result) {
echo 'Reviewer Name: ' . $result->reviewer_name . '<br>';
echo 'Reviewer URL: ' . $result->reviewer_url . '<br>';
echo 'Reviewer Text: ' . $result->reviewer_text . '<br>';
echo 'Review Time: ' . $result->review_time . '<br>';
echo 'Rating: ' . $result->rating . '<br><br>';
}
1 Like
aslotta
2
Absolutely. See the following hooks:
- Filter: bricks/setup/control_options – Bricks Academy
- Filter: bricks/query/run – Bricks Academy
- Filter: bricks/query/loop_object – Bricks Academy
And / Or a complete example:
2 Likes
pixite
3
Thank you! 
I made a gist of my code that I think is right, it appears to be working.
2 Likes