Jim R Posted February 27, 2010 Share Posted February 27, 2010 I'm not getting much on this issue, which is frustrating. When you click on a Tag, it takes you to a Tag Archive page, and that Tag has a numeric value in the database. To access that Tag value I'm using: $wp_tagID = get_query_var('tag_id'); I already know this line works, because I have a file (plugin if you will) that inputs some of my own information onto the Tag Archive page. So for my example, the tag_id = 68, which has a taxonomy of 'post_tag'. Enter my problem. I'm using an image plugin, which allows me to Tag images, and it matches those Tags to the Tags already generated by WordPress. So it would have the tag_id = 68 but have the taxonomy of 'ngg_tag'. I want to take the images with the same Tags and put them on the Tag Archive page. My Tags are usually basketball player names, so clicking on his Tag takes you to a page with his profile information and every Post tagged with his name. I'd like to also have an assortment of pictures also appear on his page (Tag Archive). Here is the code I"m trying: // Picture Code echo '<div class="pictures">'; $mf_query = <<<EOF SELECT t.*, tt.*, p.*, n.* FROM {$wpdb->posts} as p, {$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); if ($mf_terms [ 'term_id' ] == $wp_tagID) { 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>'; } // End picture code I'm not getting any errors, but in using the var_dump in there, I'm getting an array of 0. That tells me it's getting nothing from the database. Quote Link to comment https://forums.phpfreaks.com/topic/193582-wordpress-and-tags/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.