I want to run a query inside my woocommerce templates on the backend.
This will return the proper value if I do the following . . .
<?php global $wpdb; $wc = $wpdb->get_var( " SELECT meta_value FROM wp_postmeta WHERE post_id = 128 AND meta_key = '_mycustomfield' " ); echo $wc; ?>
I’m inside the woocommerce thankyou.php template at the moment and I want to filter not on post_id=128 but something along the lines of post_id=$order->post_id.
I just can’t get the syntax for this type of query. How do I specify the current order?
- The topic ‘extract database query into templates’ is closed to new replies.