This is primarily for WordPress, but I can't get anyone to help me, here (on another board) or elsewhere. When I click on a Tag on my blog, the user is taken to a Tag Archive page where any Post written tagged with that basketball player's name (most of my tags) shows up.
That Tag carries with it a value, let's 68, for example, is the term_id, and it carries the label of post_tag. I'm also using a image plugin which lets me Tag images, and if it uses the same name, it gives it the same term_id but has the label of ngg_tag. So basically, when you go to the Tag Archive page, you have all the posts which carry that tag, as well as 8 random images (per the query below) that also carry that tag.
Below is a MySQL query that links the images in ngg_pictures data table to my term_ids in another data table:
$mf_query = <<<EOF
SELECT t.*, tt.*, n.*
FROM {$wpdb->term_relationships} as tr, {$wpdb->terms} AS t, {$wpdb->term_taxonomy} AS tt, {$wpdb->ngg_pictures} AS n
WHERE tt.`taxonomy` = 'ngg_tag'
AND tt.`term_id` = t.`term_id`
AND tt.`term_taxonomy_id` = tr.`term_taxonomy_id`
AND tr.`object_id` = n.`pid`
ORDER BY rand()
LIMIT 8
EOF;
$mf_terms = $wpdb->get_results( $mf_query );
var_dump($mf_terms);
echo '
<div id="gameCenter">';
foreach ( $mf_terms as $image ) {
echo '<a href="' . $image->imageURL . '" title="' . $image->pid . '"' . $image->thumbcode . '>';
echo '<img title="' . $image->alttext . '" alt="' . $image->alttext . '" src="' . $image->thumbnailURL . '"' . $image->size . '/>';
}
echo '</div>';
I put the var_dump in there because it wasn't working. All the var_dump produces is
array(0) { } , which is to say it's not extracting anything.
Here is a sample page:
http://hoosierhoopsreport.com/tag/alexander-hutson/