Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // i will use the global variable $wpdb
- global $wpdb;
- // i get all the terms from taxonomy 'solucoes' with the ID from the loop
- $solucoes = wp_get_object_terms(get_the_ID(), 'solucoes');
- // Loop
- foreach($solucoes as $solucao) :
- // I get the thumbnail_id from the term
- $solucaoThumbnailId = $wpdb->get_results('SELECT meta_value FROM wp_postmeta WHERE post_id = "' . $solucao->term_id . '" AND meta_key = "_thumbnail_id"');
- // If my get is TRUE
- if($solucaoThumbnailId) {
- // I get the relative URL from the upload inside the wp_postmeta table
- $solucaoThumbnail = $wpdb->get_results('SELECT meta_value FROM wp_postmeta WHERE post_id = "' . $solucaoThumbnailId[0]->meta_value . '"');
- // And use this. :)
- echo '<li><a title="' . $solucao->name . '"><img src="' . get_template_directory_uri() . '../../../uploads/' . $solucaoThumbnail[0]->meta_value . '" width="50" height="50" /></a></li>';
- }
- // End loop
- endforeach;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement