Jump to content

WordPress and Tags...


Jim R

Recommended Posts

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. 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.